Urgent Help Needed Please ! - $_REQUEST Shenanigans

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
CHEESEMAKER67
Forum Newbie
Posts: 3
Joined: Thu Jun 15, 2006 9:02 am

Urgent Help Needed Please ! - $_REQUEST Shenanigans

Post by CHEESEMAKER67 »

Hi guys and gals,

I'm trying to use $_REQUEST to pull the value of an encrypted variable back off the URL. The URL looks like this :

http://www.foo.com/blah.php?encrypted=F ... xM5CAYPJwo

and I try to read it using :

$str1=$_REQUEST['encrypted'];

When I try to decrypt this it fails. However, if I put the raw string out of the URL using cut and paste into decrypt algorithm it works perfectly. I've done a comparison between what $_REQUEST gives m and what vut and paste gives me and the 2 strings are below :

Cut and paste
FDUqHR4xCjx4fg8RJDItNxM5CAYPJwo8YRx0QHh7dnd2cH5ZWHQPQQdgfyIaBRY9DiV2EltyB0MDaBtFZ2cEcXdse1lbcxpDA2hpWXlndXV+A3ldKXsBRU5+DQwLIzYtCS52Wlp1DkILa381Jzk3KzN8eVBFdxEyZQsaInhrAwkLYQYoPwF/VXI8PQYvJTEXIjI+BR9/ejJnGxExDnASKjQ1CAYPJ2UWQC01AHcbAxEECQ4tTQFhQWE9KgEmIn8IBhUIIS4GETRaPi01IzJ/dWFyDzoOIUIBVgstFT4jMXhhAgo/PX8=

$_REQUEST
FDUqHR4xCjx4fg8RJDItNxM5CAYPJwo8YRx0QHh7dnd2cH5ZWHQPQQdgfyIaBRY9DiV2EltyB0MDaBtFZ2cEcXdse1lbcxpDA2hpWXlndXV A3ldKXsBRU5 DQwLIzYtCS52Wlp1DkILa381Jzk3KzN8eVBFdxEyZQsaInhrAwkLYQYoPwF/VXI8PQYvJTEXIjI BR9/ejJnGxExDnASKjQ1CAYPJ2UWQC01AHcbAxEECQ4tTQFhQWE9KgEmIn8IBhUIIS4GETRaPi01IzJ/dWFyDzoOIUIBVgstFT4jMXhhAgo/PX8=

As you will see, the + signs in the cut and pasted one have ben converted into CR or LF in the $_REQUEST one. Has anybody any idea how I can get round this please ?

Any help much appeciated

Cheers

Cheesemaker.
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Take a look at urlencode() and htmlentities() for solutions.
CHEESEMAKER67
Forum Newbie
Posts: 3
Joined: Thu Jun 15, 2006 9:02 am

thanks but..

Post by CHEESEMAKER67 »

Thanks for the prompt reply, but I've tried both of those already without success. I've even tried using $_GET instead of $_REQUEST which gave the same result. Surely there must be some way of getting he actual string from a URL...

:(
User avatar
TheMoose
Forum Contributor
Posts: 351
Joined: Tue May 23, 2006 10:42 am

Post by TheMoose »

Maybe just replace any space character with the + sign after the request?

Code: Select all

$str1 = str_replace(" ", "+", $_REQUEST['encrypted']);
CHEESEMAKER67
Forum Newbie
Posts: 3
Joined: Thu Jun 15, 2006 9:02 am

Thanks

Post by CHEESEMAKER67 »

Wow, what a terrible cludge ! A programmer after my own heart :)

Even better is that it works !

Thanks very much to both of you who replied to my post. Much appreciated. A virtual pint on me guys !

Cheers

CheeseMaker
Post Reply