In index.php, I have created a form and in the action attribute of the form tag I have specified “page2.php”.
page2.php is also a form, (which continues on from index.php) and in the action attribute of the form tage I have specified “page3.php”. I can retrieve what the user entered into the “location” text box, in the form on index.php and display it in page2.php through the method
<?php echo $_GET["location"]; ?>
but, I now also want to display the user location in page3.php, but when I use the above method it does not work. It give me the error: “Undefined index: location”. I take it is because page3.php can not access the fields from index.php, but how do I get this to work?
Thanks in advance
You will need to store the value of $_GET[“location”]; in a hidden field on page2.php within the form that gets submitted to page3.php.
Update Example
page2.php
page3.php
What you’re doing here is printing out the contents of location into the value of a hidden field and then you’re reading this hidden field in page3.php
This is one way to do it but you might want to consider looking into the php sessions.