hanlonj Posted October 3, 2006 Share Posted October 3, 2006 I want to pass the value if a variable to another page by attaching it to the end of the href.something like this:[code]<a href "nextPage.php?myValue='My Value'">Next Page</a>[/code]I then want to grab it on the next page using like:[code]$msg = $_GET[myValue][/code]Then I want to print this value to the screen like:[code]echo $msg;[/code]I can't seem to get it to work but I think it's just a small syntax problem. Can anyone give me a snippet example of how I would go about this please or point me in the right direction?Thank you.John Link to comment https://forums.phpfreaks.com/topic/22923-using-_get/ Share on other sites More sharing options...
thepip3r Posted October 3, 2006 Share Posted October 3, 2006 change $msg = $_GET[myValue] to $msg = $_GET['myValue']. it should work this way. also, verify that the $_GET array is even seeing the variable passed. use this function on the nextpage.php to see what's in the $_GET array:[code]echo "<pre>";print_r($_GET);echo "</pre>";[/code] Link to comment https://forums.phpfreaks.com/topic/22923-using-_get/#findComment-103426 Share on other sites More sharing options...
MCP Posted October 3, 2006 Share Posted October 3, 2006 If your initial value is in PHP, you'll need to use something like:[code]<a href "nextPage.php?myValue=<?php echo urlencode($somevariable); ?>">Next Page</a>[/code] Link to comment https://forums.phpfreaks.com/topic/22923-using-_get/#findComment-103472 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.