How to read value from request query

Hi
I am very new php propgramming. But I have done classic asp.
I have a string request, eg www.xyz.com?test=1

In my php page, I would like to read test value.
On my index.php, I have this code.

<? $y=$_GET["test"]; ?>

But I am getting error, Undefined index: test in index.php.
I can see, when I call index page first time, I call just as www.xyz.com.

Please can some help.

Many thanks.

If your php looks like “www.xyz.com” then ‘test’ is not set so that is where you are getting the undefined index error message.
To solve this error from showing up when you first visit the page and no variable are sent use this

[php]
if(isset($_GET[“test”])){
$y = $_GET[“test”];
}
[/php]

Let us know if you have any other issues.

Sponsor our Newsletter | Privacy Policy | Terms of Service