hi

i want to pass the url variables from one page to another page as it is. so how can i pass those are all to nezt page. i may not know what are the var names exist in that or even i dont required. i just want to forward them to the next page and may add some more variavles to them

Dani AI

Generated

A reliable, simple server-side pattern is to reuse the raw query string and redirect the browser to the next page. That preserves all unknown parameter names (as suggested) and avoids trying to enumerate variables. The example below shows a compact ColdFusion pattern that:

  • preserves the original query string unchanged,
  • handles whether the target already has a query part,
  • safely URL-encodes only newly added values,
  • and performs a normal HTTP redirect with <cflocation>.
<cfset qs = CGI.QUERY_STRING>
<cfset target = "nextpage.cfm">

<!--- decide separator if target already contains '?' --->
<cfif find("?", target) GT 0>
  <cfset sep = "&">
<cfelse>
  <cfset sep = "?">
</cfif>

<!--- append existing query string if present --->
<cfif len(qs) GT 0>
  <cfset target = target & sep & qs>
  <cfset sep = "&">
</cfif>

<!--- add an extra variable (URLEncoded) --->
<cfset target = target & sep & "addedVar=" & URLEncodedFormat("value here")>

<cflocation url="#target#" addtoken="false">

Notes and troubleshooting:

  • Do not re-URLEncode CGI.QUERY_STRING — it is already encoded; only encode new values with URLEncodedFormat.
  • cflocation turns the request into a GET. If the original request must remain a POST, use an auto-submitted form (the client-side approach mentioned by ) or a server-side POST (CFHTTP) and handle the response accordingly.
  • Hidden fields (as noted by ) are useful when controlling a form, but they require knowing which fields to create.
  • Validate redirect targets and avoid forwarding to arbitrary external URLs to prevent open-redirect or information-leak risks. Check for duplicate parameter names (use structKeyExists(URL, 'name')) if overwriting must be prevented.

This pattern covers the common gaps in the earlier replies: it preserves unknown names, safely appends new data, and handles empty or pre-existing query parts.

Recommended Answers

All 3 Replies

Dear srinu

you pass the variable as form object like that.......

<input type="hidden" name="variable_name" id="value_of_variable">

regards
Mbabar

Hi,

Try using cgi variable Query_String to get information regarding url variable and pass the same to the next page...

Regards
Shy

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.