Best practice to pass variables in url?

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
tech0925
Forum Commoner
Posts: 47
Joined: Wed Nov 09, 2011 2:46 pm

Best practice to pass variables in url?

Post by tech0925 »

Hello,

I was wondering what the best method to passing variables in the url would be if you wanted to hide the variable from being so obvious? What I am passing is not sensitive at all but was just curious. I know I could use urlencode to remove spaces and etc..

Ex:

Code: Select all

php?id=1234
This is not sensitive data but it is obvious. I have noticed sites that instead of it looking like that it looks like:

Code: Select all

an-innovative-iphone-developer-game-curriculum-kids/27095603/?backurl=aHR0cHM6Ly93d3cuZWxhbmNlLmNvbS9yL2pvYnMvY2F0LXdlYi1wcm9ncmFtbWluZw==
I am curious to what the cuZWxhbmNlLmNvbS9yL2pvYn is and why, how, and when would I use such a method. Is this md5?

Thanks!
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Best practice to pass variables in url?

Post by Celauran »

Doesn't look like they're doing anything significantly different. I can't say for certain, of course, but I'd guess that 27095603 is the article ID. 'an-innovative-iphone-developer-game-curriculum-kids' is a slug which may or may not be needed to display the article, but makes the title a little friendlier. Finally, and I'm still guessing here, based on the name, backurl is probably a reference to the referring page/site.
tech0925
Forum Commoner
Posts: 47
Joined: Wed Nov 09, 2011 2:46 pm

Re: Best practice to pass variables in url?

Post by tech0925 »

Oh ok. So it is perfectly fine to have a url that looks like php?id=1234 ? Just wanted to make sure that I was doing it correctly. Let's say that the data I wanted to pass was sensitive, what method do I use in that case?

Thanks for the quick reply! You have always been very helpful! :)
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Best practice to pass variables in url?

Post by Celauran »

I'd use POST over GET for more sensitive information.
tech0925
Forum Commoner
Posts: 47
Joined: Wed Nov 09, 2011 2:46 pm

Re: Best practice to pass variables in url?

Post by tech0925 »

Ok, thanks!
Post Reply