I have an input form in which the user fills in several fields. I want to display the contents of these fields on a page right after the user hits submit. I am not sure how to call the last entered record.

Also, to further complicate the issue, there is the potential that any number between 1 and 4 rows can be created based on data entered in the form so I am not sure how to specify the number of records to call on the "review page" because it changes every time. I would appreciate any guidance/advice and would be happy to provide more details if needed.

Can you show us the code you have written so far? That way it will be much easier to show you how to go about it.

Thanks for the reply. The following code is what I have so far. It creates 4 rows in the db. However, I do not want to create rows for fields if they have no value. For example, if there is no p3_firstname, I do not want it to create a row in the db...

But back to the initial question, I was simply hoping to display the data from this form on the "review.php" page after hitting submit. I am lost on how to start out this review page. Thanks in advance for any advice.


//connect to database
include 'global.php';

$case = date(ymdHis);

if ($_POST['register_case'])
 //get form data
 $p1_firstname = addslashes(strip_tags($_POST['p1_firstname']));
 $p1_lastname = addslashes(strip_tags($_POST['p1_lastname']));
 $p2_firstname = addslashes(strip_tags($_POST['p2_firstname']));
 $p2_lastname = addslashes(strip_tags($_POST['p2_lastname']));
 $p3_firstname = addslashes(strip_tags($_POST['p3_firstname']));
 $p3_lastname = addslashes(strip_tags($_POST['p3_lastname']));
 $p4_firstname = addslashes(strip_tags($_POST['p4_firstname']));
 $p4_lastname = addslashes(strip_tags($_POST['p4_lastname']));
 $city = addslashes(strip_tags($_POST['city']));
 //register into database
 $register_case = mysql_query ("INSERT INTO cases VALUES 

header ('Location: review.php');
exit ();


If you only wish to display the data entered in the form directly on another page then what you have to do is very simple. With PHP, you need two separate pages but you can use one page too.
Let's assume that your form is on page1.php and you want to preview it on page2.php you will do something like this.


echo "<form method = 'post' action = 'page2.php'>";
echo "<input type = 'text' name = 'fullname'/>";
echo "<input type = 'submit' name = 'preview' value = 'PREVIEW'/>";
echo "</form>";

On page2.php you can disply the content of the text field using the code below

echo $_POST['fullname'];

The main idea is to set action of form to the page where you to show the preview.

Thanks, that was exactly what I was looking for.