[Solved] Adding PHP Form Data to Existing MySQL Table via Separate Form


If I’m understanding, you are inserting new user information from Form 1 and then sending the user to a new page with a new form to fill out added information. Correct? … If so, simply retrieve the ID from the table where they were inserted and use that to insert data from Form 2.

This would be done in 3 queries. On the first page, your new user will be inserted into the table with a simple insert query and then the ID of the insert will be placed in a SESSION variable:

$con = mysqli_connect("localhost", "my_user", "my_password", "world");
$query = "INSERT INTO table Name, Address, Phone VALUES fullname, addr, phone1";
mysqli_query($con, $query);

$_SESSION['id'] = mysqli_insert_id($con);

Then on page 2, use the ID in the session variable to complete the 2nd insert query.

6

solved Adding PHP Form Data to Existing MySQL Table via Separate Form