Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Pass a URL as a variable in the URL

Posted on 2005-05-13
7
Medium Priority
?
220 Views
Last Modified: 2013-12-24
Is it possible to pass a URL as a variable in the URL?  If so, how would I do it?

Phil Hayes
0
Comment
Question by:SiriusPhil
7 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 14000362
Hi SiriusPhil,

What do you mean? Like:

http://www.example.com/url.php?url=http://someotherexample.com/

? Yes, that's possible and you would get it out of the URL just like any other GET variable. I have no idea about ColdFusion syntax but it would be like that. Just make sure to URLEncode the URL first.

Regards,
Zyloch
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 14000510
yeah it's possible

Like this

startpage.cfm
----------------------

<cfset MyVarr = "Http://www.yourdomain.cfm">

<form name="myform" action="actionpage.cfm?VariableOne=#MyVarr#" method="post">

...form elements...

...submit button....

</form>

actionpage.cfm
------------------------------------------
<cfparam name="url.VariableOne" default="">

<cfoutput>

My URL Variable: #Url.VariableOne#<br>

<a href="#Url.VariableOne#"> Here's the link</a>

</cfoutput>
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 14000535
URLEncodedFormat(string [, charset ])

oops forgot to account for the URLEncodedFormat

here:

startpage.cfm
----------------------

<cfset MyVarr = "http://www.yourdomain.cfm">

<form name="myform" action="actionpage.cfm?VariableOne=#URLEncodedFormat(MyVarr)#" method="post">

...form elements...

...submit button....

</form>

actionpage.cfm
------------------------------------------
<cfparam name="URL.VariableOne" default="">
<cfset MyVarr = URLDecode(URL.VariableOne)>

<cfoutput>

My URL Variable: #MyVarr#<br>

<a href="#MyVarr#"> Here's the link</a>

</cfoutput>


there ya go ;o)
~trail
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 

Author Comment

by:SiriusPhil
ID: 14000543
Woops..

Forgot to tell you one thing...

Some of the URL's I want to send as variables have variables in them too.

Can I send somethong like...

http://foo.com?id=1

through a URL variable?



0
 
LVL 35

Accepted Solution

by:
mrichmon earned 500 total points
ID: 14000572
Not a problem - send as shown above by trialblazzyr55

<cfset MyVarr = "http://www.yourdomain.cfm">

<form name="myform" action="actionpage.cfm?VariableOne=#URLEncodedFormat(MyVarr)#" method="post">

 BUT for accessing you would want to do this:

<cfset passedURL = ListLast(URL, "VariableOne=")>

where VariableOne is whatever you name the url variable that will contain the passed url.

Make sure that any other url variables are before the passed URL in the original URL
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 14000580
here:

startpage.cfm
----------------------
<cfset next = SomethingElse">
<cfset mysecond = "Something">
<cfset MyVarr = "http://www.yourdomain.cfm?mySecond=#SecondVarr#&next=#next#">

<cfset extra = "AdditionalVariables">

<form name="myform" action="actionpage.cfm?MyURL=#URLEncodedFormat(MyVarr)#&extra=#extra#" method="post">

...form elements...

...submit button....

</form>

actionpage.cfm
------------------------------------------
<cfparam name="URL.MyURL" default="">
<cfset MyVarr = URLDecode(URL.MyURL)>

<cfparam name="URL.extra" default="">
<cfset extra = URL.extra>

<cfoutput>

My URL Variable: #MyVarr#<br>
My Extra Variables: #extra#<br>

<a href="#MyVarr#"> Here's the link</a>

</cfoutput>
0
 
LVL 20

Expert Comment

by:trailblazzyr55
ID: 14000590
yeah good catch mrichmon, pass any additional url variables before the passedURL

also you make a good point about accessing variables in the passed url.

between the two posts that should cover what you are looking to do ;o)

~trail
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question