Advertisement
SquidNuggett113

Untitled

Feb 9th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. header.php
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <title>Official MVMS Chromebook Database</title>
  6. <meta name="description" content="The Chromebook Database used by MVMS, Running MariaDB, PHP, Apache">
  7. <link rel="stylesheet" type="text/css" href="styles/style1.css">
  8. </head>
  9. <body>
  10. <div id="wrapper-main">
  11. <header>
  12. <div id="navtotable">
  13. <center>
  14. <a href="table.php">Show Table Of Computers</a>
  15. </center
  16. </div>
  17. <div id="spacer">
  18. </div>
  19. <div id="insertform">
  20. <form action="includes/insert.inc.php" method="post">
  21. <center>
  22. <input class="input" type="text" name="roomNum" placeholder="Room Number"></input>
  23. <input class="input" type="text" name="teacher" placeholder="Teacher"></input>
  24. <input class="input" type="text" name="frontID" placeholder="Barcode On Front"></input>
  25. <input class="input" type="text" name="barcode" placeholder="Barcode On Bottom"></input>
  26. <br>
  27. <input class="button" type="submit" name="submit" value="Insert Into Database!"></input>
  28. </center>
  29. </form>
  30. </div>
  31. </header>
  32. ----------------------------------------------------------
  33. dbh.inc.php
  34. <?php
  35. $servername = "localhost";
  36. $dBUsername = "root";
  37. $dBPassword = "";
  38. $dBName = "chromebook";
  39.  
  40. $conn = mysqli_connect($servername, $dBUsername, $dBPassword, $dBName);
  41.  
  42. if (!$conn) {
  43. die("Connection Failed: ".mysqli_connect_error());
  44. }
  45. ----------------------------------------------------------------------
  46. insert.inc.php
  47. <?php
  48.  
  49. // added error reporting
  50. error_reporting(E_ALL);
  51. ini_set('display_errors', 1);
  52.  
  53. require "dbh.inc.php";
  54.  
  55. $RoomNum = $_POST["roomNum"];
  56. $Teacher = $_POST["teacher"];
  57. $FrontId = $_POST["frontID"];
  58. $Barcode = $_POST["barcode"];
  59.  
  60. $sql = "INSERT INTO chrome (RoomNum, Teacher, FrontId, Barcode) VALUES ($RoomNum, $Teacher, $FrontId, $Barcode)";
  61.  
  62. if ($conn->query($sql) === TRUE) {
  63. echo "New Laptop Added Successfully";
  64. } else {
  65. echo "Error: " . $sql . "<br>" . $conn->error;
  66. }
  67.  
  68. $conn->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement