Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // php code to Insert data into mysql database from input text
- //include_once '../../testadmin/controlpanel/test/testnew/dbcon.php';
- $DB_host = "localhost";
- $DB_user = "crazyfix_admin";
- $DB_pass = "Msx361";
- $DB_name = "crazyfix_garage";
- $MySQLiconn = new MySQLi($DB_host,$DB_user,$DB_pass,$DB_name);
- if($MySQLiconn->connect_errno)
- {
- die("ERROR : -> ".$MySQLiconn->connect_error);
- }
- if(isset($_POST['insert']))
- {
- $firstname = $_POST['firstname'];
- $lastname = $_POST['lastname'];
- $address1 = $_POST['address1'];
- $address2 = $_POST['address2'];
- $city = $_POST['city'];
- $postcode = $_POST['postcode'];
- $telephonenumber = $_POST['telephonenumber'];
- $email = $_POST['email'];
- $vehicleregistration = $_POST['vehicleregistration'];
- $makemodel = $_POST['makemodel'];
- $jobdate = $_POST['jobdate'];
- $jobtime = $_POST['jobtime'];
- $servicedetails = $_POST['servicedetails'];
- $query = "INSERT INTO `customer`(`firstname`, `lastname`, `address1`, `address2`, `city`, `postcode`, `telephonenumber`, `email`) VALUES ('$firstname','$lastname','$address1', '$address2', '$city', '$postcode', '$telephonenumber', '$email');
- SELECT LAST_INSERT_ID() INTO @lastID
- INSERT INTO `vehicle`(`vehicleregistration`, `make&model`, 'customernumber') VALUES ('$vehicleregistration','$makemodel', @lastID);
- INSERT INTO `job`(`jobdate`, `jobtime`, `servicedetails`, 'customernumber') VALUES ('$jobdate','$jobtime','$servicedetails', @lastID)";
- if ($MySQLiconn->multi_query($query))
- {
- do{
- if ($result = $MySQLiconn->story_result())
- {
- while ($row = $result->fetch_row())
- {
- printf("%s\n", $row[0]);
- }
- $result->free();
- }
- if ($MySQLiconn->more_results())
- {
- printf("-----------------------\n");
- }
- } while ($mysqli->next_result());
- }
- $MySQLiconn->close();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement