Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing GET parameter strings containing '&'

    Im wanting to pass a URL as a parameter to another URL:

    e.g.
    http://localhost/test.php?param=http...?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'

  • #2
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Percent encode the special characters.
    Code:
    param=http%3A%2F%2Fwww.foo.com%2Ftest.php%3Fp1%3Dabc%26p2%3D=def
    (not checked)

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts
    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
    Last edited by mOrloff; 11-26-2008 at 01:15 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •