Inserting in two tables from one form
Posted: Fri Apr 07, 2006 12:23 pm
How would I go about inserting information into two tables from one form? This is my current code which is not working.
Code: Select all
<?php
if(isset($_POST['add'])) {
mysql_connect ("address", "user", "pass") or die ('Error connecting to mysql');
mysql_select_db (database);
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$company = $_POST['company'];
$status = $_POST['status'];
$date = $_POST['entry_date'];
$query = "INSERT INTO job (fname,lname,company,status,entry_date) VALUES ('$fname','$lname', '$company','$status',current_date)";
mysql_query($query) or die ('cannot insert');
$jnum = $_POST['jobid'];
$jname = $_POST['title'];
$jdes = $_POST['des'];
$date = $_POST['insert_date'];
$queryb = "INSERT INTO jinfo (jobid, title, des, insert_date) VALUES ('$jnum','$jname','$jdes',current_date)";
mysql_query($queryb) or die ('cannot insert');
header('Location: index.php');
}
?>