rod Posted January 28, 2007 Share Posted January 28, 2007 hia,anyway know what's the problem with the following code ?<HTML><BODY> <div align=center> <A href="?page=1">Page 1</A> - <A href="?page=2">Page 2</A> - <A href="?page=3">Page 3</A> </div><hr><? switch($page) { case "1" :?>Page 1<? break; case "2" :?>Page 2<? break; case "3" :?>Page 3<? break; default:?>Welcome<?}?></BODY></HTML>for reasons unknown, the quetystring doesn't seem to work with my web server ? is there any configuration settings that need changing ?Rod Link to comment https://forums.phpfreaks.com/topic/36043-help-with-query-string/ Share on other sites More sharing options...
matto Posted January 28, 2007 Share Posted January 28, 2007 try changing this:[code]switch($page) {[/code]to this[code]switch($_GET['page']) {[/code] ;) Link to comment https://forums.phpfreaks.com/topic/36043-help-with-query-string/#findComment-171057 Share on other sites More sharing options...
rod Posted January 28, 2007 Author Share Posted January 28, 2007 it works...thanks,why doesn't php create de variable 'page' automaticaly ?rod Link to comment https://forums.phpfreaks.com/topic/36043-help-with-query-string/#findComment-171062 Share on other sites More sharing options...
matto Posted January 28, 2007 Share Posted January 28, 2007 It would if you had register_globals set to on in your php.ini file. This is now set to off by default. It's good practice to use $_POST['var'] rather than $var for post variables and $_GET['var'] rather than $var for variables you pass in the url. I don't know how many times I have seen people fall into this trap..... ;) Link to comment https://forums.phpfreaks.com/topic/36043-help-with-query-string/#findComment-171063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.