Advertisement
Metropes

Untitled

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