Klance Posted April 3, 2008 Share Posted April 3, 2008 I have a tree here: http://24.177.36.183/test/tree/index.php But after I click Guitar Hero, if i click PS2 more than one, it will add that onto the url over and over, same with the difficulties, how do I stop it so that if you click it more than once, nothing will happen? Here is index.php: <a href="?game=GH">Guitar Hero</a><br /> <?php if (!empty($_GET['game']) && file_exists("./$_GET[game].php")) { include("./$_GET[game].php"); } ?> Here is GH.php: <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&console=PS2">PS2</a><br /> <?php if (!empty($_GET['console'])) { include("./$_GET[console].php"); } ?> Here is PS2.php: <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&diff=Easy">Easy</a> | <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&diff=Medium">Medium</a> | <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&diff=hard">Hard</a> | <a href="<?php echo $_SERVER['REQUEST_URI'] ?>&diff=Expert">Expert</a> | <br /> <?php if (!empty($_GET['diff'])) { include("scores.php"); } ?> Thanks in advance. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 3, 2008 Share Posted April 3, 2008 Because your are using $_SERVER['REQUEST_URI'] it contains everything in the url, including query strings. This is why it keeps adding &diff=whatever when you go PS2.php Use $_SERVER['SCRIPT_NAME'] or $_SERVER['PHP_SELF'] Quote Link to comment Share on other sites More sharing options...
devstudio Posted April 3, 2008 Share Posted April 3, 2008 Change all of your link references to look like these: To Select Game: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=GH">Guitar Heo</a> To Select Console: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=PS2">PS2</a> To Select Difficulty: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Easy">Easy</a> <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Medium">Medium</a> [etc...] Best, Nathan Quote Link to comment Share on other sites More sharing options...
Klance Posted April 3, 2008 Author Share Posted April 3, 2008 Change all of your link references to look like these: To Select Game: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=GH">Guitar Heo</a> To Select Console: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=PS2">PS2</a> To Select Difficulty: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Easy">Easy</a> <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Medium">Medium</a> [etc...] Best, Nathan Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.