Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Databases Exercise</title>
  4. </head>
  5. <body style="background-color:#00b8e6;width:80%;margin-left:auto;margin-right:auto;margin-top:40px;text-align:center;@import url('https://fonts.googleapis.com/css?family=Montserrat');font-family: 'Montserrat', sans-serif;">
  6.  
  7. <h1>
  8. Welcome, Please Input Your Car Data!
  9. </h1>
  10.  
  11.  
  12. <h3>Vehicles Database</h3>
  13.  
  14. <?php
  15.  
  16. $servername = "localhost";
  17. $username = "admin";
  18. $dbname = "dbx";
  19. $password = "";
  20.  
  21.  
  22. $insQl = "";
  23. $mysqli = new mysqli ($servername, $username, $password, $dbname);
  24. $result = $mysqli->query ('SELECT * FROM cars');
  25.  
  26. $userRegistration = $temporary = $userManufacturer = $userVehicleModel = $userProductionYears = $userEngineModel = "";
  27.  
  28.  
  29. $userRegistration = ($_POST["rego"]);
  30. $userManufacturer = ($_POST["make"]);
  31. $userVehicleModel = ($_POST["model"]);
  32. $userProductionYears = ($_POST["years"]);
  33. $userEngineModel = ($_POST["motor"]);
  34.  
  35.  
  36. ?>
  37.  
  38.  
  39.  
  40. <form action="index.php" method="POST" style="border:1px solid black; padding:20px;margin-bottom:30px;">
  41. <ul style="list-style:none;">
  42. <li style="margin-bottom:20px;border:1px solid black;padding:15px;">Registration:<input style="margin-left:40px;" type="text" name="rego" value="<?php echo $userRegistration ?>"></li>
  43. <li style="margin-bottom:20px;border:1px solid black;padding:15px;">Manufacturer:<input style="margin-left:40px;" type="text" value="<?php echo $userManufacturer ?>" name="make"></li>
  44. <li style="margin-bottom:20px;border:1px solid black;padding:15px;">Vehicle Model:<input style="margin-left:40px;" type="text" value="<?php echo $userVehicleModel ?>" name="model"></li>
  45. <li style="margin-bottom:20px;border:1px solid black;padding:15px;">Production Years:<input style="margin-left:40px;" type="text" value="<?php echo $userProductionYears ?>" name="years"></li>
  46. <li style="margin-bottom:20px;border:1px solid black;padding:15px;">Engine Model:<input style="margin-left:40px;" type="text" value="<?php echo $userEngineModel ?>" name="motor"></li>
  47. <li style="margin-bottom:20px;border:1px solid black;padding:15px;"><input style="margin-left:40px;width:80px;height:35px;" type="button" value="Submit" name="submitButton"></li>
  48. </ul>
  49. </form>
  50.  
  51. <?php
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. // if (isset($_POST['rego'])){
  60. // echo $_POST['rego'];
  61. // echo 'TEST WORKING';
  62. // }
  63.  
  64. $insQL = $mysqli->query("INSERT INTO cars (Registration, Manufacturer, Vehicle_Model, Production_Years, Engine_Model) VALUES ("' . $_POST['rego'] . '", "' . $_POST['make'] . '" , "' . $_POST['model'] . '", "' . $_POST['years'] . '", "' . $_POST['motor'] . '")';
  65.  
  66.  
  67.  
  68. echo "<table><tr><th>Registration &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Manufacturer &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Vehicle Model &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Production Years &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Engine Model &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th></tr>";
  69.  
  70.  
  71.  
  72.  
  73. // if ($result->num_rows > 0) {
  74. // echo "<table><tr><th>Registration &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Manufacturer &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Vehicle Model &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Production Years &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th><th>Engine Model &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</th></tr>";
  75. while ($row = $result->fetch_assoc()) {
  76. echo "<tr><td>" . $row["Registration"] . "</td><td>" . $row["Manufacturer"] . "</td><td>" . $row["Vehicle_Model"] . "</td><td>" . $row["Production_Years"] . "</td><td>" . $row["Engine_Model"] . "</td></td></tr>";
  77. }
  78. echo "</table>";
  79. // } else {
  80. // echo "0 results";
  81. // }
  82.  
  83.  
  84. require 'footer.php';
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement