Urlencoding Question

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
phibertek
Forum Newbie
Posts: 8
Joined: Thu Aug 23, 2007 12:34 pm

Urlencoding Question

Post by phibertek »

Hello,

I am trying to pass a link from siteA to siteB in the format below:

http://www.siteB.com/my.php?e%3D%16%84% ... 5%B7%5D%A3

This string is a blowfish encrypted string that I am trying to send over from siteA to siteB. I've encoded the URL because of all the special characters. On siteB I am trying to do a echo $_REQUEST['e'], but there is no value for 'e' when the URL is passed. Do I have to decode it first? And if so, can someone help me understand the process?

Regards,

-Ptek
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
phibertek
Forum Newbie
Posts: 8
Joined: Thu Aug 23, 2007 12:34 pm

Sample Site

Post by phibertek »

VladSun,

The url I supplied is an example. I'm trying not to publish the customer's site because I am working on a security detail. I need help with the concept of urldecoding urlencoded data passed in a url.

-Ptek
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

I've just pointed that it is not a proper URL - you missed the "=" sign after "e"...

I've always used base64encode for this issue.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

The full url should not be encoded. Only the "values" of the GET variables. Encoding the full url also encodes the "=" which is required to identify the variable names.
phibertek
Forum Newbie
Posts: 8
Joined: Thu Aug 23, 2007 12:34 pm

AYI YI!

Post by phibertek »

VladSun,

Thank you dearly!

Ptek
phibertek
Forum Newbie
Posts: 8
Joined: Thu Aug 23, 2007 12:34 pm

Actually!

Post by phibertek »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is my test.  am I encoding the wrong thing?

Code: Select all

$encr = new pcrypt(MODE_ECB, "BLOWFISH", "secretkey");
$test = $encr->encrypt("This is Ptek");
$link = "e=$test";
$val = urlencode($link);
echo "$val<br>";
echo "<a href=http://www.siteB.com/my.php?$val>Click Me</a>";

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by phibertek on Wed Aug 29, 2007 10:18 am, edited 1 time in total.
phibertek
Forum Newbie
Posts: 8
Joined: Thu Aug 23, 2007 12:34 pm

Nevermind, I seee

Post by phibertek »

Thanx! Yes, it works! Thank you for pointing that out!

-Ptek
Last edited by phibertek on Wed Aug 29, 2007 10:23 am, edited 1 time in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Yes, it's wrong :)

Code: Select all

$encr = new pcrypt(MODE_ECB, "BLOWFISH", "secretkey");
$test = $encr->encrypt("This is Mark");
$val = "e=" . urlencode($test);
echo "$val<br>";
echo "<a href=http://www.siteB.com/my.php?$val>Click Me</a>";
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply