Hello all, hope you are well.

I have a form split over 4 pages. I want to pass the data from each page to a session and then insert it into the database.

I am not sure what I've done wrong but fields from the last page get put into the first few fields of the database instead of where they should be, and the rest are blank.

Here's the codes:

Top of page 2 before any html code
PHP Code:
session_start();
 

$_SESSION['name'] = $_POST['os0'];
$_SESSION['number'] = $_POST['os1'];
$_SESSION['email'] = $_POST['os2']; 
Page 3
PHP Code:
session_start();
 
 
$_SESSION['collection_date'] = $_POST['os4'];
$_SESSION['address'] = $_POST['address']; 
Page 4
PHP Code:
session_start();

$_SESSION['packkit'] = $_POST['os5'];
$_SESSION['delivery'] = $_POST['on6'];
$_SESSION['additems'] = $_POST['os7']; 
php to insert into database
PHP Code:
<?php
session_start
();

$con mysql_connect("XXXX","XXXXX","XXXXX");
if (!
$con)
  {
  die(
'Could not connect: ' mysql_error());
  }

mysql_select_db("XXXXX"$con);

$number mysql_real_escape_string(preg_replace('/[^0-9]/'''$_SESSION['number']));

$realname mysql_real_escape_string($_SESSION['name']);

$email mysql_real_escape_string($_SESSION['email']);

$address mysql_real_escape_string(preg_replace('/[\r\n]/',' ',$_SESSION['address']));

$collection mysql_real_escape_string($_SESSION['collection_date']);

$packingkit mysql_real_escape_string($_SESSION['packkit']);

$delivery mysql_real_escape_string($_SESSION['delivery']);

$additems mysql_real_escape_string($_SESSION['additems']);

$tandc mysql_real_escape_string($_POST['tandc']);

$sql="INSERT INTO Orders (Name, Number, Email, Size, Address, Collection_Date, Packing_kit, Delivery_date, Additional_Items, Date_received, Terms, Deposit)
VALUES
('
$realname','$number','$email','Standard','$address','$collection','$packingkit','$delivery','$additems', date_format(curdate(),'%d-%m-%Y'),'$tandc', 'Yes')";

if (!
mysql_query($sql,$con))
{
die(
'Error: ' mysql_error());
}
echo 
"";

mysql_close($con)
?>
Can anyone see what I'm doing wrong here?

Thanks in advance for any input, it is much appreciated.

Kind regards, Mike