Page 1 of 1

Seperating superglobals

Posted: Sun May 21, 2006 8:04 pm
by tommy1987
Hi,

I want to seperate out superglobals to read them in again, like the following:


http://www.blahblah.co.uk/blah.php?id=4565np=123123

where id and np should be read into a form and their respective values. PHP doesnt seem to recognise that they are both individual and cant distinguish that id=4565 and np=123123.

Hope someone can help, im sure its extremely simple, Thanks, Tom

Posted: Sun May 21, 2006 8:15 pm
by RobertGonzalez
PHP distinguishes querystring parameters through get. In your case (blah.php?id=4565np=123123) checking for these vars in the superglobal array $_GET would easily reveal their values to you.

Code: Select all

<?php
if (isset($_GET['id']))
{
    echo $_GET['id'] . ' is the id var value...<br />';
}

if (isset($_GET['np']))
{
    echo $_GET['np'] . ' is the np var value...<br />';
}
?>

Posted: Sun May 21, 2006 8:57 pm
by Christopher
You would use $_GET, but you need to separate the name=value pairs with ampersands, such as:

Code: Select all

www.blahblah.co.uk/blah.php?id=4565&np=123123

Posted: Sun May 21, 2006 8:58 pm
by Ambush Commander
I don't think Everah noticed the missing ampersand. :roll: (just to make sure the poster doesn't get confused with extra info)

Posted: Sun May 21, 2006 9:29 pm
by RobertGonzalez
Got that right. Looked right over it. 8O