Title: Saving into multiple table Post by: karogel on November 01, 2015, 06:02:54 PM Please help...how to create save.php file with multiple table, say save to personalinfo.php and address.php
I am following or using this simple code for saving to single table: <?php $firstname = htmlspecialchars($_REQUEST['firstname']); $lastname = htmlspecialchars($_REQUEST['lastname']); $phone = htmlspecialchars($_REQUEST['phone']); $email = htmlspecialchars($_REQUEST['email']); include '../conn.php'; $sql = "insert into users(firstname,lastname,phone,email) values('$firstname','$lastname','$phone','$email')"; $result = @mysql_query($sql); if ($result){ echo json_encode(array( 'id' => mysql_insert_id(), 'firstname' => $firstname, 'lastname' => $lastname, 'phone' => $phone, 'email' => $email )); } else { echo json_encode(array('errorMsg'=>'Some errors occured.')); } ?> Title: Re: Saving into multiple table Post by: dies_felices on November 03, 2015, 09:24:54 AM Hi,
The simplest answer is a mysqli multi-line query: Code:
You would be much better off using stored procedures to do this as that is much safer. |