...

View Full Version : Passing GET parameter strings containing '&'



tomfoster29
11-25-2008, 09:19 PM
Im wanting to pass a URL as a parameter to another URL:

e.g.
http://localhost/test.php?param=http://www.foo.com/bar.php?p1=abc&p2=def

Is there a way make the parameter treat the url passed as a single string so that it doesnt interfere with the original URL?

i.e. param = 'http://www.foo.com/test.php?p1=abc&p2=def'

Apostropartheid
11-25-2008, 09:46 PM
Percent encode the special characters.

param=http%3A%2F%2Fwww.foo.com%2Ftest.php%3Fp1%3Dabc%26p2%3D=def
(not checked)

mOrloff
11-26-2008, 12:12 AM
I'm kinda a newbie to all coding, so I hope I correctly understand what your looking for, and that my reply is applicable.

Another (PHP) solution I've used is to just pass a single value, then use a switch/case function to interpret that into the multiple values you want.
IE: if you are looking for a date range, you could have a radio button for Last Month, and just have a case that assigns values to the $fromDate and $ toDate vars using the date() function.

An additional bonus is that this creates a more secure form. If someone tried something malicious by customizing the $_GET contents, it couldn't do anything because your switch() func will only utilize pre-defined values in a predefined way.

Just another option.

~ Mo



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum