1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Encoding/Decoding URL for GET

Discussion in 'PHP & Perl' started by maple_toast, Apr 15, 2011.

  1. maple_toast

    maple_toast Newbie

    Joined:
    Jul 23, 2008
    Messages:
    30
    Likes Received:
    50
    I thought I found this answer somewhere on here a while back, but now I can't find it.

    I'm trying to do a simple base64_encode($url) via an email link. Then pass the variables to the if(isset($_GET statement)). However, it's not working for me.

    Is it even possible to do this? To bas64_decode($url) and then GET it?

    Thanks all...
     
  2. gnote

    gnote Registered Member

    Joined:
    Mar 10, 2009
    Messages:
    80
    Likes Received:
    6
    Occupation:
    Programmer
    Location:
    USA
    are you trying to base64 the entire url? or you are trying to do pass the vars like ?vars=$base64ed

    if the latter it should work if you say if (isset($_GET['vars'])) then base64_decode($_GET['vars'])

    otherwise provide more information if you want help
     
  3. takita

    takita Newbie

    Joined:
    Jun 20, 2009
    Messages:
    28
    Likes Received:
    70
    base64 encoding includes the symbols "+" and "=" in the encoded texts (in most, that is)

    And that may mess up your URL as the .htaccess generally doesnt allow those symbols in a url.

    So replace "+" and "=" with something like "7PLUS7" and "7EQUALS7" and then pass it through, then when $_GETing it, replace "7PLUS7" etc with the symbol then decode that.

    Enjoy!
     
    • Thanks Thanks x 1
  4. maple_toast

    maple_toast Newbie

    Joined:
    Jul 23, 2008
    Messages:
    30
    Likes Received:
    50
    Thanks!!!
     
  5. other_henry

    other_henry Junior Member

    Joined:
    Jun 1, 2011
    Messages:
    107
    Likes Received:
    19
    Occupation:
    Freelance coder, server guy
    Location:
    US
    Use 'rawurlencode' for encoding URLs, it handles spaces correctly for that purpose