Jump to content

accessing GET variables


jimfog

Recommended Posts

Suppose we have the following code:

<li><a href=" ' . $_SERVER["PHP_SELF"] . "?nest=" . $test . ' ">click here</a></li>

If i wanted to access nest i would write:

if (isset($_GET['nest'])) {

The question is, what is the syntax to access $test?Because we might have the following code:

<a href=" ' . $_SERVER["PHP_SELF"] . "?nest=" . $test . ' ">Click here</a><a href=" ' . $_SERVER["PHP_SELF"] . "?nest=" . $test1 . ' ">Click here1</a>

and i want to grab only $test1-with if (isset($_GET['nest'])) i access both of them sth i do not want.

Link to comment
Share on other sites

Give them different names instead of calling them both nest if you need to distinguish between them.
Ok besides that, is there a way accessing them, without changing the name of "nest"? I am asking out of curiosity.
Link to comment
Share on other sites

You can split the string... like

echo '<a href="' . $_SERVER["PHP_SELF"] . "?nest=" . $test . '">Click here</a>';if (isset($_GET['nest'])) {echo '<a href="' . $_SERVER["PHP_SELF"] . "?nest=" . $test1 . '">Click here1</a>';}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...