Advertisement
Metropes

Untitled

May 2nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. <?php
  2.  
  3. // php code to Insert data into mysql database from input text
  4. //include_once '../../testadmin/controlpanel/test/testnew/dbcon.php';
  5.  
  6.  
  7. $DB_host = "localhost";
  8. $DB_user = "crazyfix_admin";
  9. $DB_pass = "Msx361";
  10. $DB_name = "crazyfix_garage";
  11.  
  12. $MySQLiconn = new MySQLi($DB_host,$DB_user,$DB_pass,$DB_name);
  13.  
  14. if($MySQLiconn->connect_errno)
  15. {
  16. die("ERROR : -> ".$MySQLiconn->connect_error);
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23. if(isset($_POST['insert']))
  24. {
  25. $firstname = $_POST['firstname'];
  26.     $lastname = $_POST['lastname'];
  27.     $address1 = $_POST['address1'];
  28.     $address2 = $_POST['address2'];
  29.     $city = $_POST['city'];
  30.     $postcode = $_POST['postcode'];
  31.     $telephonenumber = $_POST['telephonenumber'];
  32.     $email = $_POST['email'];
  33.     $vehicleregistration = $_POST['vehicleregistration'];
  34.     $makemodel = $_POST['makemodel'];
  35.     $jobdate = $_POST['jobdate'];
  36.     $jobtime = $_POST['jobtime'];
  37.     $servicedetails = $_POST['servicedetails'];
  38.    
  39.    
  40.  
  41.    
  42.     $query = "INSERT INTO `customer`(`firstname`, `lastname`, `address1`, `address2`, `city`, `postcode`, `telephonenumber`, `email`) VALUES ('$firstname','$lastname','$address1', '$address2', '$city', '$postcode', '$telephonenumber', '$email');
  43. SELECT LAST_INSERT_ID() INTO @lastID
  44. INSERT INTO `vehicle`(`vehicleregistration`, `make&model`, 'customernumber') VALUES ('$vehicleregistration','$makemodel', @lastID);
  45. INSERT INTO `job`(`jobdate`, `jobtime`, `servicedetails`, 'customernumber') VALUES ('$jobdate','$jobtime','$servicedetails', @lastID)";
  46.  
  47. if ($MySQLiconn->multi_query($query))
  48. {
  49.     do{
  50.         if ($result = $MySQLiconn->story_result())
  51.         {
  52.             while ($row = $result->fetch_row())
  53.             {
  54.                 printf("%s\n", $row[0]);
  55.             }
  56.             $result->free();
  57.         }
  58.         if ($MySQLiconn->more_results())
  59.         {
  60.             printf("-----------------------\n");
  61.         }
  62.     } while ($mysqli->next_result());
  63. }
  64. $MySQLiconn->close();
  65.  
  66. }
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement