Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Databases Exercise</title>
- </head>
- <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;">
- <h1>
- Welcome, Please Input Your Car Data!
- </h1>
- <h3>Vehicles Database</h3>
- <?php
- $servername = "localhost";
- $username = "admin";
- $dbname = "dbx";
- $password = "";
- $insQl = "";
- $mysqli = new mysqli ($servername, $username, $password, $dbname);
- $result = $mysqli->query ('SELECT * FROM cars');
- $userRegistration = $temporary = $userManufacturer = $userVehicleModel = $userProductionYears = $userEngineModel = "";
- $userRegistration = ($_POST["rego"]);
- $userManufacturer = ($_POST["make"]);
- $userVehicleModel = ($_POST["model"]);
- $userProductionYears = ($_POST["years"]);
- $userEngineModel = ($_POST["motor"]);
- ?>
- <form action="index.php" method="POST" style="border:1px solid black; padding:20px;margin-bottom:30px;">
- <ul style="list-style:none;">
- <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>
- <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>
- <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>
- <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>
- <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>
- <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>
- </ul>
- </form>
- <?php
- // if (isset($_POST['rego'])){
- // echo $_POST['rego'];
- // echo 'TEST WORKING';
- // }
- $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'] . '")';
- echo "<table><tr><th>Registration        </th><th>Manufacturer        </th><th>Vehicle Model        </th><th>Production Years        </th><th>Engine Model        </th></tr>";
- // if ($result->num_rows > 0) {
- // echo "<table><tr><th>Registration        </th><th>Manufacturer        </th><th>Vehicle Model        </th><th>Production Years        </th><th>Engine Model        </th></tr>";
- while ($row = $result->fetch_assoc()) {
- 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>";
- }
- echo "</table>";
- // } else {
- // echo "0 results";
- // }
- require 'footer.php';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement