[Wolves] PHP variables from URL

David Goodwin david at openminds.co.uk
Mon Dec 29 16:31:43 GMT 2003


On Mon, 2003-12-29 at 16:24, Matthew Revell wrote:
> Howdy,
> 
> Second newbie type PHP question of the day!
> 
> I've really tried hard to find the answer to this one but can't, so I turn
> to you lot as my last resort :)
> 
> How the faggot do I find use a variable that has been passed to my script
> in the URL? For example:
> 
> article.php?id=1
> 
> How do I then get hold of the fact that id has been set to 1 in the URL?
> 
> Cheers all :)
> 
> Matt.
> 


Katherine's been asking me similar questions all day!

Assuming register globals is turned off in your php.ini file, where ever that may lie, 

Try :

$_GET['variableName']

or 

$_POST['variableName']

$_GET and $_POST are global arrays. There is also $_ENV, $_SESSION and $_SERVER I believe, but I've not used PHP lately, so may be wrong.


If register globals was on, then PHP would automatically populate $variableName for you to use (i.e no Array stuff needed). This caused quite a lot of security problems with people writing rubbish scripts, so it's been turned off by default since about v4.0


Thanks
David.
(wonder why evolution has lost line wrap?)





More information about the Wolves mailing list