<?php
echo '
<form action="form2.php">
User's ID: <input type="text" name="ID_1" /><br>
User Name 1: <input type="text" name="Add_Name_1" /><br>
<input type="checkbox" name="certainbox" value="N" /><br>
<input type="submit" name="submit" />
</form>';
?>
<php
if($_POST["submit"]) {
if ($_POST["certainbox"] == "N") {
include form5.php;
}
else {
include form3.php;
}
}
?>
<?php
echo '
<form action="form4.php">
User name 2: <input type="text" name="Add_Name_2" /><br>
User name 3: <input type="text" name="Add_Name_3" /><br>
<input type="hidden" name="ID_1" value="'.$_POST["ID_1"].'" />
<input type="hidden" name="Add_Name_1" value="'.$_POST["Add_Name_1"].'" />
<input type="submit" name="submit" />
</form>';
?>
<?php
# don't actually insert raw $_POST into table, cleanse it first.
#connect to your database and run update query example
$query = "
UPDATE `tbl` SET NAME1 = \"'.mysql_real_escape_string($_POST["Add_Name_1"]). '\",
NAME2 = \"'.mysql_real_escape_string($_POST["Add_Name_1"]). '\",
NAME3 = \"'.mysql_real_escape_string($_POST["Add_Name_1"]). '\"
WHERE ID = \"'.mysql_real_escape_string($_POST["ID_1"]). '\"
";
$result = mysql_query($query);
echo 'data updated';
?>
<?php
# don't actually insert raw $_POST variables into table, cleanse it first.
#connect to your database and run update query example
$query = "
UPDATE `tbl` SET NAME1 = \"'.mysql_real_escape_string($_POST["Add_Name_1"]). '\"
WHERE ID = \"'.mysql_real_escape_string($_POST["ID_1"]). '\"
";
$result = mysql_query($query);
echo 'data updated';
?>
Page 1: Keyin data for main record (this is where the 1st $post data comes from)... to this:
Page 2: If certain check box is "N", go to page 5.
else
Page 3: Keyin more data.
Page 4: Write record and save new values for original record
Page 5: Write/Update main record
Page 1. Create an empty database record, set a cookie with the record id, then put up the form for keying in the data.Now you have a design where the client, if interrupted, can come back to the process and pick up where they left off. Add a bit of garbage collection to remove empty records after some time, and you're good to go.
Page 2. Using the cookie id and the contents of the form from page 1, update the database. If a certain checkbox is "N" redirect the client to page 5.
Page 3: Key in more data, on submit, go to page 4
Page 4: Using the cookie id and the contents of the form from page 3, update the database.
Page 5: Produce the appropriate response, etc.
I knew about $_SESSION. I was trying not to use it.Good grief, why not? It's as easy as pie to persist data in the session, although by now you should be aware of the risks of data loss when using the session over longer periods of time. If you don't need long persistence, session is perfect. If you need long persistence, then you want to use something more like this:
http://php.net/manual/en/tutorial.forms.php
Understanding HTTP requests:
https://www.experts-exchange.com/articles/11271/Understanding-Client-Server-Protocols-and-Web-Applications.html
Passing data between HTTP requests... This is one way:
https://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html
Another, better way is to update the data model with each client input. Each form script draws its information from the database. Each action script writes its collected data back into the database.
https://www.experts-exchange.com/articles/12335/PHP-and-MySQLi-Table-Maintenance.html