Hi Folks
I am working on a forum for a customer and I am having problems passing a url variable;
This the code i have on a search page
<cfelseif cgi.http_referer contains 'forumViewMessages'><cfset linktext = 'Forum Postings/Replies Page'><cfset lastpage = 'forumViewMessages.cfm?#linkVariables#'>
</cfif>
<cfoutput>#lastpage#</cfoutput>
<cfabort>
the output on the page when i run this is;
forumViewMessages.cfm?topicID=284&catID=8&category=Bird Breeding

When the form is submitted to the results page;
<form name="form1" method="post" action="forumsearchresults.cfm?lastpage=<cfoutput>#lastpage#</cfoutput>">

it shows in the status bar that ALL the variables are being passed, so up to here is OK.

Where my problem starts is when i get to the results page and when i run;
<cfoutput>#url.lastpage#</cfoutput>
<cfabort>
on that page the output page shows just;
forumViewMessages.cfm?topicID=284

Can anyone please explain or give me a reason why the whole string is not being passed. Does it have anything to do with the ampersand after the topicID (topicID=284&)

Your help would be greatly appreciated
thanks in advance
Grabit

Any time parameter values contains special characters, you have to encode them ie Use UrlencodedFormat

You have to remove the / character in your url string.

No. Nothing wrong with using reserved characters. As long as they're encoded properly.

<cfif not(isdefined("url.lastpage"))>
		<cfset lastpage="testera.cfm?topicID=284&catID=8&category=Bird Breeding">
            <form method="post" action="testera.cfm?lastpage=#lastpage#">
            <input type="submit" />
            </form>
    <cfelse>
        #url.lastpage#
        #url.catID#
    </cfif>

Actually there is nothing wrong... Not only lastpage variable but everything else is passed as url variables as well...

There is if you're passing reserved characters (like spaces) without escaping them. You're supposed to url encode them .. not hope the browser does it for you automatically ;)

Hi Folks
I am working on a forum for a customer and I am having problems passing a url variable;
This the code i have on a search page
<cfelseif cgi.http_referer contains 'forumViewMessages'><cfset linktext = 'Forum Postings/Replies Page'><cfset lastpage = 'forumViewMessages.cfm?#linkVariables#'>
</cfif>
<cfoutput>#lastpage#</cfoutput>
<cfabort>
the output on the page when i run this is;
forumViewMessages.cfm?topicID=284&catID=8&category=Bird Breeding

When the form is submitted to the results page;
<form name="form1" method="post" action="forumsearchresults.cfm?lastpage=<cfoutput>#lastpage#</cfoutput>">

it shows in the status bar that ALL the variables are being passed, so up to here is OK.

Where my problem starts is when i get to the results page and when i run;
<cfoutput>#url.lastpage#</cfoutput>
<cfabort>
on that page the output page shows just;
forumViewMessages.cfm?topicID=284

Can anyone please explain or give me a reason why the whole string is not being passed. Does it have anything to do with the ampersand after the topicID (topicID=284&)

Your help would be greatly appreciated
thanks in advance
Grabit

Hi Grabit,
First of all let me know you what has happened to your url.
By default url query string is splitted at '&'. and when you sent query string as "forumsearchresults.cfm?lastpage=forumViewMessages.cfm?topicID=284&catID=8&category=Bird Breeding", the query string was splitted as
1. lastpage=forumViewMessages.cfm?topicID=284
2. catID=8
3. category=Bird Breeding.

So when you used url.lastpage, it only got you "lastpage=forumViewMessages.cfm?topicID=284".

Now the solution for you:

Join the individual query strings and store them in variables.link variable. Use it to create your link.

<cfset variables.myLink = url.lastPage &"&amp;catId=" & url.catId & "&amp;category="&url.category>
<cfoutput><a href="#variables.myLink#">My link</a></cfoutput>

Hope fully this will help you out. Still if you have any doubts, then please come forward with your set of questions.

Thanks

Dipak

If you have gone through the post and found your issue fixed then please mark it as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.