Forum Moderators: coopster
Let's say you have three pages: form.php, process.php, and results.php. On form.php, you would just have your simple HTML form, but make sure the form begins like this:
<form method="post" action="process.php"> That method="post" part is important. Remember to give all of the elements of your form valid names as well.
Now, in process.php, you will grab all of the form data from form.php. This is through the use of the $_POST array. $_POST has every element from the form on form.php in it for you to access/process as you please. (For example ... if you have an input box in form.php named "email_address", then to access the value of the element in process.php, simply use the variable $_POST["email_address"]. With that knowledge, you can process any of the variables as you see fit.
Now, if you want to print the results on results.php, there are many methods to approach. The easiest, I'd say, would be through the $_GET variable. It works exactly the same as $_POST, but only in that it's an array :-). In process.php, you'll want to redirect to results.php, but you'll want to pass a query string along with it. I can explain this best by example:
Let's say you want the result to read, simply, "Success". You would redirect from process.php to results.php by using the following at the end of your PHP code:
header("Location: results.php?theresult=Success"); This is assuming that headers have yet to be sent; that is, the only code on process.php is PHP code (as it should be anyway). Then, on results.php, simply print out the variable you passed: $_GET['theresult'] (theresult is the variable in the url above).