I have an html page that gathers data without problems. The form tag on that page is <form id="maininput" name="maininput" action='orderpage.php' method='post' enctype='multipart/form-data' > That passes data to orderpage.php perfectly because I can see it when I use print_r() to display it. In the header, I then assign the POST variables to php variables using statements like: if (!isset($firstname)) {$firstname = $_POST['firstname'];} After assigning the variables to php variables, I display the variables in another form on this page with the following tag: <form name="readyforPayPal" onSubmit="return checkAgreement();" method="POST"> checkAgreement is a Javascript function that makes sure that the customer has checked a checkbox on this page. The submit tag is <input type='submit' id="gotopaypal" name='gotopaypal' value="Submit" /> Everything is fine and all data is available both in $_POST and in the php variables until I click submit. After I click submit, all of the variables lose their value and become unset. Why is this happening? or better question: How do I preserve the variables and still require the user to verify that their data is correct and that they want to proceed with the order. Thank you for any help
You can either use session variables to keep the values or use hidden input fields. See the following page for examples: Creating a multi-page form using PHP Passing PHP form variables from one page to other
Another option is to add a value="" attribute to your form fields, and use server-side scripting to rewrite the page to insert the data you want to be persistent, into the value field (eg. value="{insertion-point}" becomes value="inserted_value"). Use a template for the form, with unique find-and-replace target text inserted in place of the persistent data, and then use 'str_replace' to replace the target text with your persistent data values. Alternatively, use a standardized target text string for all your insertion points, and 'explode' the form template into an array, using the target text as the separator string for the 'explode' function. You'll end up with your form template code broken up into sections, which are stored in whatever array you used for the 'explode' function. You then wrap the sections around the values you wish to insert into the form (eg. $form_code = $section[0] . $_REQUEST['$value1'] . $section[1] . $_REQUEST['$value2'] . $section[2] . $_REQUEST['$value3'] . $section[3]; ). This method can be useful where you need to insert the values in parallel.
Thank you so much. You gave me the right path to follow. However, instead of session_register, I used the following at the top of the page: session_start(); foreach ($_POST as $key => $value){ $_SESSION[$key] = $value; } That page you gave me suggest using session_register(). When I looked it up on PHP.NET, I found the following warning message on the page about session_register(): This function (talking about session_register) has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged. That may cause a lot of people pain later on Thanks again