elias Posted March 21, 2006 Share Posted March 21, 2006 Hi guys and galsI am baffled by the inability to send variables accross two pages through a form...This is a little experiment I set up to see exactly what was going on:Form Page:[code] <form action="test_print.php" method="post"> <input type="text" name="site_id" value="something" size="30"> <input type="submit" value="Send"> </form> [/code]Print Page (test_print.php):[code] $site_id = $_GET["site_id"]; print "$site_id";[/code]And the result is a blank page.Then I tried directly on the browser:[code]http://www.domain.com/test_print.php?site_id=something[/code]and that worked - I got the word "something" printed.I have to add that I have moved server and all these pages worked before.Also, someone has already suggested the use of $_GET["site_id"]; - which I dont know exactly what it does, but it does seem to make it work when variables are passed from one page to the other via the URL.Can someone shed some light as to what is going on and how to fix it.TIAtahiche Quote Link to comment Share on other sites More sharing options...
craygo Posted March 21, 2006 Share Posted March 21, 2006 Well first you are using a method of POST but trying to get the value with GET.They need to match.this[code]$site_id = $_GET["site_id"]; print "$site_id";[/code]Should be[code]$site_id = $_POST["site_id"]; print "$site_id";[/code]Using method=GET in your form, you will see the values in the URL, that is why the page works when you put the value in the address. But in your form you are using method=POST, so in order to retrieve the variable on the next page you have to use the above code.If the methog is POST then all variable references should be POSTRay Quote Link to comment Share on other sites More sharing options...
elias Posted March 21, 2006 Author Share Posted March 21, 2006 Hi RayThanks a bunch for the explanation, I will do some further studying to make sure I undestand it thoroughly.I just did not know where to turn.Thanks again and have a good one!!tahiche Quote Link to comment 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.