Hi All,
I am trying to creat a form that will submit data to multiple tables in the same database. I am using the code below, but this seems to only be writing data to the last table in the query.
<?php
$con = mysql_connect("localhost","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("databasename", $con);
$sql="INSERT INTO staff_churn
(username
,reference
,champ
,churn_type
,effective_date
,department
,exit_department
,position
,contract_type)
VALUES
('$_POST[username]'
,'$_POST[reference]'
,'$_POST[fname]'
,'$_POST[churn_type]'
,'$_POST[effective_date]'
,'$_POST[department]'
,'$_POST[exit_department]'
,'$_POST[position]'
,'$_POST[contract_type]'
)";
$sql="INSERT INTO staff_churn_access
(reference
,access_card
,champ_portal
,desktop
,email
,hard_phone
,lan
,laptop
,soft_phone
,g_drive
,g_folders
,h_drive
,h_folders
,distribution
,clarify_access)
VALUES
('$_POST[reference]'
,'$_POST[access_card]'
,'$_POST[champ_portal]'
,'$_POST[desktop]'
,'$_POST[email]'
,'$_POST[hard_phone]'
,'$_POST[lan]'
,'$_POST[laptop]'
,'$_POST[soft_phone]'
,'$_POST[g_drive]'
,'$_POST[g_drive] $_POST[drive_a] $_POST[drive_c] $_POST[drive_e] $_POST[drive_g]'
,'$_POST[h_drive]'
,'$_POST[h_drive] $_POST[drive_b] $_POST[drive_d] $_POST[drive_f] $_POST[drive_h]'
,'$_POST[list_a] $_POST[list_b] $_POST[list_c] $_POST[list_d] $_POST[list_e] $_POST[list_f] $_POST[list_g] $_POST[list_h]'
,'$_POST[clarify_access]'
)";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>";
include "/submit/redirect_churn.html";
mysql_close($con)
?>
Can anyone help here?