Return to Snippet

Revision: 41399
at February 17, 2011 07:53 by stephcode


Initial Code
footer.php:

<ul>
    <li><a href="city.php?city=<?php echo urlencode("Blerg County"); ?>&state=<?php echo urlencode("Massachusetts"); ?>">Blerg County</a></li>
 </ul>

city.php:

<?php echo urldecode($_GET['city']); ?>
and
<?php echo urldecode($_GET['state']); ?>

solution:

echo isset($_GET['city']) ? htmlentities($_GET['city']) : 'your city';

Initial URL


Initial Description
If user enters city.php from footer.php, page will return certain string. If user enters independently, solution lets user see predefined string (in this case, 'your city').

Initial Title
Handy PHP thing I can\'t come up with a title for; display different data depending on where user comes from, sort of

Initial Tags
php

Initial Language
PHP