dh526 Posted May 21, 2009 Share Posted May 21, 2009 Firstly, thank you for looking ! Now for the question, is it possible to enter details from a form into 2 Access tables at once? This is the sort of thing I want to do : <form method="post" action="register.php"> <table border = 0> <tr> <td>Username: </td> <td> <input type="text" name="username" /></td> <td> Please choose a unique username </td> </tr> <tr> <td>Forename: </td> <td> <input type="text" name="forename" /></td> </tr> <tr> <td>Surname: </td> <td> <input type="text" name="surname" /> </td> </tr> <tr> <td>DOB: </td> <td> <input type="text" name="dob" /> </td> <td>Please enter in the form of dd/mm/yyyy</td> </tr> <tr> <td>Email: </td> <td> <input type="text" name="email" /> </td> </tr> <tr> <td><br></td> </tr> <tr> <td>House Number: </td> <td> <input type="text" name="housenumber" /> </td> </tr> <tr> <td>Street: </td> <td> <input type="text" name="street" /> </td> </tr> <tr> <td>Town: </td> <td> <input type="text" name="town" /> </td> </tr> <tr> <td>Postcode: </td> <td> <input type="text" name="postcode" /> </td><td> enter in the form of LL99 9LL </td> </tr> <tr> <td> <input type="submit"></td> <td> </td> </tr> </form> </table> and the php file: <?php $username= $_POST ['username']; $surname = $_POST ['surname']; $forename = $_POST ['forename']; $dob = $_POST ['dob']; $email = $_POST ['email']; $housenumber = $_POST ['housenumber']; $street = $_POST ['street']; $town = $_POST ['town']; $postcode = $_POST ['postcode']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblCustomer (username, Surname, Forename, DOB, [Email Address]) VALUES ('$username', '$surname','$forename', '$dob','$email')"; $sql2="INSERT INTO tblAddress (username, HouseNumber, Street, Town, Postcode) VALUES ('$username', '$housenumber','$street', '$town','$postcode')"; if (odbc_exec($conn,$sql,$sql2)) { echo "Welcome, Your records have been added to our system"; } odbc_close($conn); ?> Is this possible?? Or not? Thank you for looking Quote Link to comment Share on other sites More sharing options...
sellfisch Posted May 21, 2009 Share Posted May 21, 2009 I only worked with mysql until yet, but you could try: $sql="INSERT INTO tblCustomer (username, Surname, Forename, DOB, [Email Address]) VALUES ('$username', '$surname','$forename', '$dob','$email');"; $sql.="INSERT INTO tblAddress (username, HouseNumber, Street, Town, Postcode) VALUES ('$username', '$housenumber','$street', '$town','$postcode')"; if (odbc_exec($conn,$sql)... Quote Link to comment Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 No. You would need to execute two seperate queries. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.