DavidGS Posted December 28, 2007 Share Posted December 28, 2007 I know this is a rather trivial question, but how do I go about setting the value of a variable through a URL? Like, say you had a page which has "tabs" and for each tab you want to display different content. To make sure the user sees the right tab, you would use something like http://example.com/index.php?tab=1 When I try to set the value of a variable that way it doesn't return anything. print "$pageid"; with the URL http://localhost/index.php?pageid=1 Nothing is printed because pageid doesn't have a value. But if I try defining the variable in the script: $pageid = 1; It returns whatever value I defined it with instead. What is right way of using variables in your URL? Quote Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/ Share on other sites More sharing options...
Northern Flame Posted December 28, 2007 Share Posted December 28, 2007 $pageid = $_GET['tab']; echo $pageid; Quote Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424503 Share on other sites More sharing options...
DavidGS Posted December 28, 2007 Author Share Posted December 28, 2007 $pageid = $_GET['tab']; echo $pageid; Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424505 Share on other sites More sharing options...
Northern Flame Posted December 28, 2007 Share Posted December 28, 2007 you're welcome Quote Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424506 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.