Guest User

Untitled

a guest
Mar 23rd, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <style>
  6. h1{
  7. text-align: center;
  8. }
  9. </style>
  10. <title> CRUD</title>
  11. </head>
  12. <body>
  13. <h1> CRUD Management</h1>
  14.  
  15. <!--Create Row-->
  16. <h2> Create new Entry </h2>
  17. <form>
  18. <p>
  19. <label for="ID">ID:</label>
  20. <input type="text" name="id" id="id">
  21. </p>
  22. <p>
  23. <label for="creator">Creator:</label>
  24. <input type="text" name="creator" id="creator">
  25. </p>
  26. <p>
  27. <label for="title">Title:</label>
  28. <input type="text" name="title" id="title">
  29. </p>
  30. <p>
  31. <label for="type">Type:</label>
  32. <input type="text" name="type" id="type">
  33. </p>
  34. <p>
  35. <label for="identifier">Identifier:</label>
  36. <input type="text" name="identifier" id="identifier">
  37. </p>
  38. <p>
  39. <label for="date">Date:</label>
  40. <input type="date" name="date" id="date">
  41. </p>
  42. <p>
  43. <label for="language">Language:</label>
  44. <input type="text" name="language" id="language">
  45. </p>
  46. <p>
  47. <label for="description">Description:</label>
  48. <input type="text" name="description" id="description">
  49. </p>
  50. <input type="submit" value="Submit" action="insert.php" method="post">
  51. </form>
  52. <table>
  53. <h2>Retrieve Data</h2>
  54. <thead>
  55. <tr>
  56. <th>ID</td>
  57. <th>Creator</td>
  58. <th>Title</td>
  59. <th>Type</td>
  60. <th>Date</td>
  61. <th>Identifier</td>
  62. <th>Language</td>
  63. <th>Description</td>
  64. </tr>
  65. </thead>
  66. <tbody>
  67. <tr>
  68. <td><?php echo $row['id']?></td>
  69. <td><?php echo $row['creator']?></td>
  70. <td><?php echo $row['title']?></td>
  71. <td><?php echo $row['type']?></td>
  72. <td><?php echo $row['date']?></td>
  73. <td><?php echo $row['identifier']?></td>
  74. <td><?php echo $row['language']?></td>
  75. <td><?php echo $row['description']?></td>
  76. </tr>
  77.  
  78. </tbody>
  79. </table>
  80. </body>
  81. </html>
  82.  
  83.  
  84.  
  85. <a href="/a3/createForm.html" target="_parent"><button>Create</button></a>
  86.  
  87. <a href="/a3/retrieve.php" target="_parent"><button>Retrieve</button></a>
  88.  
  89. <a href="/a3/updateForm.html" target="_parent"><button>Update</button></a>
  90.  
  91. <a href="/a3/deleteForm.html" target="_parent"><button>Delete</button></a>
  92. </body>
  93. </html>
  94.  
  95. <?php
  96. $servername = "localhost";
  97. $username = "root";
  98. $password = "ChontaeMi";
  99. $dbname = "cs230assignment3";
  100. // Create connection
  101. $link = mysqli_connect($servername, $username, $password, $dbname);
  102. // Check connection
  103. if ($link === false) {
  104. die("Connection failed: " . mysqli_connect_error());
  105. }
  106. $ID = mysqli_real_escape_string($link, $_REQUEST['id']);
  107. $creator = mysqli_real_escape_string($link, $_REQUEST['creator']);
  108. $type = mysqli_real_escape_string($link, $_REQUEST['type']);
  109. $title = mysqli_real_escape_string($link, $_REQUEST['title']);
  110. $identifier = mysqli_real_escape_string($link, $_REQUEST['identifier']);
  111. $date = mysqli_real_escape_string($link, $_REQUEST['date']);
  112. $language = mysqli_real_escape_string($link, $_REQUEST['language']);
  113. $description = mysqli_real_escape_string($link, $_REQUEST['description']);
  114.  
  115. $sql = "INSERT INTO ebook_metadata (id, creator, title, type, identifier, date, language, description)
  116. VALUES ('$ID', '$creator', '$title', '$type', '$identifier', '$date', '$language','$description')";
  117.  
  118. /* if(mysqli_query($link, $sql)){
  119. echo "Records added successfully.";
  120. } else{
  121. echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
  122. } */
  123.  
  124. mysqli_close($link);
  125. ?>
Add Comment
Please, Sign In to add comment