Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- header.php
- <!DOCTYPE html>
- <html>
- <head>
- <title>Official MVMS Chromebook Database</title>
- <meta name="description" content="The Chromebook Database used by MVMS, Running MariaDB, PHP, Apache">
- <link rel="stylesheet" type="text/css" href="styles/style1.css">
- </head>
- <body>
- <div id="wrapper-main">
- <header>
- <div id="navtotable">
- <center>
- <a href="table.php">Show Table Of Computers</a>
- </center
- </div>
- <div id="spacer">
- </div>
- <div id="insertform">
- <form action="includes/insert.inc.php" method="post">
- <center>
- <input class="input" type="text" name="roomNum" placeholder="Room Number"></input>
- <input class="input" type="text" name="teacher" placeholder="Teacher"></input>
- <input class="input" type="text" name="frontID" placeholder="Barcode On Front"></input>
- <input class="input" type="text" name="barcode" placeholder="Barcode On Bottom"></input>
- <br>
- <input class="button" type="submit" name="submit" value="Insert Into Database!"></input>
- </center>
- </form>
- </div>
- </header>
- ----------------------------------------------------------
- dbh.inc.php
- <?php
- $servername = "localhost";
- $dBUsername = "root";
- $dBPassword = "";
- $dBName = "chromebook";
- $conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
- if (!$conn) {
- die("Connection Failed: ".mysqli_connect_error());
- }
- ----------------------------------------------------------------------
- insert.inc.php
- <?php
- // added error reporting
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- require "dbh.inc.php";
- $RoomNum = $_POST["roomNum"];
- $Teacher = $_POST["teacher"];
- $FrontId = $_POST["frontID"];
- $Barcode = $_POST["barcode"];
- $sql = "INSERT INTO chrome (RoomNum, Teacher, FrontId, Barcode) VALUES ($RoomNum, $Teacher, $FrontId, $Barcode)";
- if ($conn->query($sql) === TRUE) {
- echo "New Laptop Added Successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement