It is currently Sat Jun 22, 2024 11:22 pm

All times are UTC

Forum rules

Please click here to view the forum rules

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PHP: Retrieve ? Parameters from calling URL
PostPosted: Thu Aug 24, 2006 3:08 pm 

Joined: Wed Aug 23, 2006 6:17 am
Posts: 20
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.

e.g. http://test.php/var1/one/var2/two



I did quite a bit of searching last night in googe, but nothing I found seemed to work on my 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.

 Post subject:
PostPosted: Thu Aug 24, 2006 4:19 pm 

Joined: Wed Aug 23, 2006 6:17 am
Posts: 20
PsychoticDude85 wrote: 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 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.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ]  Moderators: KJ, fhmagic, Moderators, Support Team

All times are UTC

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
100WebSpace © 2011