I am trying to use one form to insert data into 2 tables.
I have one table, Members and another, Members.
Here is my code:
<?php $first_name=$_POST[first_name]; $last_name=$_POST[last_name]; $email_address=$_POST[email_address]; $staff=$_POST[staff]; $type=$_POST[type]; $descr=$_POST[descr]; $time=$_POST[time]; mysql_select_db("cl49-vogclients", $con); $sql="INSERT INTO member (first_name,last_name,email_address) VALUES ('$first_name','$last_name','$email_address')"; if (!mysql_query($sql,$con)) { die('Error adding client ' . mysql_error()); } mysql_close($con); echo' <h2><font color="green">Client Added Succesfuly</font> </h2>'; $sql1="INSERT INTO audit (staff,type,descr) VALUES ('$staff','$type','$descr')"; if (!mysql_query($sql1,$con)) { die('Audit Unsucsessful ' . mysql_error()); } mysql_close($con); echo' <h2><font color="green">Audit Succesful</font> </h2>'; This adds the client/member but not add anything to the audit database?
mysql_*functions anymore, they are deprecated. See Why shouldn't I use mysql_* functions in PHP? for details. Instead you should learn about prepared statements and use either PDO or MySQLi. If you can't decide which, this article will help you. If you pick PDO, here is a good tutorial.