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
Seperating superglobals
Moderator: General Moderators
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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 />';
}
?>- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
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(#10850)
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA