|100 Web Space
|PHP: Retrieve ? Parameters from calling URL
|Page 1 of 1|
|Author:||wilbue [ Thu Aug 24, 2006 3:08 pm ]|
|Post subject:||PHP: Retrieve ? Parameters from calling URL|
I wanted, just for fun, since I am teaching myself some PHP and MySQL, to write a php program which can retrieve parameters from the URL which calls it.
I did quite a bit of searching last night in googe, but nothing I found seemed to work on my 100webspace.com site.
Someone did mention in another post that the version of php here is a much older one.
If anyone has some actual code example that will work on this site, I would really appreciate seeing it posted.
It has something to do with accessing $PATH_INFO
it may be an Apache issue, Apache option "AcceptPathInfo On"
I wanted to write a routine to send an email to a new user, to validate the account. I thought perhaps the URL could be to a php routine which would
get a parameter from the URL, and know which user to validate.
I suppose I could achieve the same thing in a less elegant way by including some random password in the e-mail, and asking the user to enter it when prompted. But that is more clumsey than just simply having the user click on the link, and everything else is automatic.
I mean, I could generate a php page for each pending user, and when they click on it, it would have the code to go into mysql and set some validated flag to true,... but then I would have all these URLs lying around, which seems more clumsey, less desirable.
|Author:||wilbue [ Thu Aug 24, 2006 4:19 pm ]|
http://yoursite.com/get.php?thisvar=steve could function something like this:
$avariable = htmlspecialchars($_GET['thisvar']); // retrieve and sanitise thisvar from the URL.
echo $avariable; // outputs 'thisvar'.
Note that it IS possible on 100webspace servers to access the variable as $thisvar instead of $_GET['thisvar'], but this (register_globals) is a security issue (I will explain why if you want) and so it is being depreciated and removed by PHP 6, so it's best to use the $_GET globals.
More information on $_GET vars
You can then use mod_rewrite on Apache to make this variable something like http://yoursite.com/get/steve by making that URL use the previous URL without redirecting the user (so it looks like get/steve, but it is actually get.php?thisvar=steve still).
More information on Mod_Rewrite
Wow! The code you gave me works like a charm! Thanks! These snippets of working code really help me to make some progress in teaching myself.
|Page 1 of 1||All times are UTC|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group