A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: passing values with PHP.. But with more problems

  1. #1
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91

    passing values with PHP.. But with more problems

    Well, first off, it's pretty easy to pass values to another page.. i can't see why sooo many people have a problem with it..
    PHP Code:
    Filename.php?Value=whatever 
    See? simple..
    Now.. I have a more complex problem.. I am passing a value that is a URL.. or at lest part of it, so it looks more like this:
    PHP Code:
    Filename.php?value=URL.html 
    still pretty easy.. But then, that URL is often, in my case, a PHP file with it's own value that need to be passed..
    PHP Code:
    Filename.php?value=URL.php?value2=
    Well.. I'm getting to the question the long way. Now, the problem is what happens when the the URL has 2 values being passed?
    PHP Code:
    Filename.php?value=URL.php?value2=b&value3=
    Because of that &, it reads it as part of the Original set of variables being passed, NOT the second. I need to know if it can be somehow put in with the second one. Why? well.. It's a nice bit of Redirection code. Basically, if you enter my site from outside the frame setup, it's all set up to go to the frames and load up the page you were just at. It all works fine until you have to put 2 values in because of that &. I'm pretty sure putting the bit within speech marks doesn't work and i got the bad feeling there really isn't any way of doing this so it works right, but i thought it's worth a try. Basically, i want
    happens when the the URL has 2 values being passed?
    PHP Code:
    Filename.php?value="URL.php?value2=b&value3=C" 
    but that doesn't seam to want to work. Any ideas?

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    You need to url encode the ? and any extra weird character.

    For example:
    Code:
    Filename.php?value=URL.php%3Fvalue2%3Db%26value3%3DC
    That's the url encoded equivalent to what you're trying to do.

    For reference: http://www.albionresearch.com/misc/urlencode.php

    Also, might I add, if you're working in PHP, there is a urlencode() function that will do it for you.
    Last edited by MyFriendIsATaco; 08-15-2009 at 06:29 PM.

  3. #3
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91
    Ah, completely forgot about URL encoding ^_^; need to put a decoding bit into the code now but that shouldn't be a problem.

    Thanks alot ^_^

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    You won't need to decode. That should be done automatically.

  5. #5
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91
    okay.. odd.. for some reason.. something isn't happy about working right now.. oh well, i'll probebly figure that out.. hope it isn't STILL the problem with passing values in the URL bit which itself is a value to another bit...

  6. #6
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    It must be something else in your code, because I just tested with this:
    PHP Code:
    <?php header('Location: '.$_GET['url']); ?>
    and it redirects any URL I throw at it just fine.

    I hit it by accessing:
    Code:
    redirect.php?url=http%3A%2F%2Fwww.example.com%2F%3Fvar1%3Da%26var2%3Db

  7. #7
    Member Manic_Man's Avatar
    Join Date
    Dec 2007
    Location
    Hastings, England
    Posts
    91
    i'm pretty sure it's something odd in the my code cause for some reason, instead of the URL, it returns 'Undefined'. So i'm just double checking things ^_^

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center