Simple PHP $_GET variable


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. home.php:
  2.  
  3. <p><a href="city.php?city=New_York_City">New York</a></p>
  4.  
  5. <p><a href="city.php?city=Boston">Boston</a></p>
  6.  
  7. city.php:
  8.  
  9. <p>Welcome to <?php echo $_GET['city'] ?> !</p>
  10.  
  11. OR -
  12.  
  13. home.php:
  14.  
  15. <p><a href="city.php?city=<?php echo urlencode("New York City"); ?>">New York</a></p>
  16.  
  17. <p><a href="city.php?city=Boston">Boston</a></p>
  18.  
  19. <p><a href="city.php?city=Rockville">Rockville</a></p>
  20.  
  21. city.php:
  22.  
  23. <p>Welcome to <?php echo urldecode($_GET['city']); ?> !</p>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.