Advertisement
Guest User

Untitled

a guest
Sep 14th, 2014
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $mysqli = new MySQLi('localhost', 'root', '11111', 'CAR_PARKING_SYSTEM');
  4.  
  5. $sql = <<< SQL
  6.     INSERT INTO `CUSTOMER_VEHICLE` (
  7.         `V_License_No`,
  8.         `D_License_No`,
  9.         `Arrived_Time`,
  10.         `Charge`
  11.     ) VALUES (
  12.         ?, ?, ?, ?
  13.     );
  14. SQL;
  15.  
  16. $stmt = $mysqli->prepare($sql);
  17. if ($stmt === false) {
  18.     die('Could not prepare SQL: '.$mysqli->error);
  19. }
  20.  
  21. $ok = $stmt->bind_param('sssi', $vLicense, $dLicense, $arrived, $charge);
  22. if ($ok === false) {
  23.     die('Could not bind params: '.$stmt->error);
  24. }
  25.  
  26. $vLicense = filter_input(INPUT_POST, 'V_License_No', FILTER_SANITIZE_STRING);
  27. $dLicense = filter_input(INPUT_POST, 'D_License_No', FILTER_SANITIZE_STRING);
  28. $arrived  = date('H:i');
  29. if (isset($_POST['vehicle_type']) && $_POST['vehicle_type'] === 'four_wheel') {
  30.     $charge = 50;
  31. } else {
  32.     $charge = 400;
  33. }
  34.  
  35. if ($stmt->execute() === false) {
  36.     die('Could not execute query: '.$stmt->error);
  37. } else {
  38.     echo '<p>Query executed successfully!</p>';
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement