Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "inventory";
  7.  
  8. $conn = new mysqli ($servername, $username, $password, $dbname);
  9.  
  10. if($conn->connect_error){
  11. die("Connection Failed:" . $conn->connect_error);
  12. }
  13.  
  14.  
  15. // (script post[""]) same sa = (name="" sa form)
  16. $bookid=$_POST['bookid'];
  17. $title=$_POST['title'];
  18. $author=$_POST['author'];
  19. $accountnumber=$_POST['accountnumber'];
  20. $callnumber=$_POST['callnumber'];
  21.  
  22. $sql = mysqli_query("INSERT INTO data (bookid,title,author,accountnumber,callnumber)
  23. VALUES ('$_POST'['title']','$_POST'['author']','$_POST'['accountnumber']','$_POST'['callnumber]')");
  24. if ($conn->query($sql) === TRUE) {
  25. header("Location:add.php");
  26. }
  27.  
  28. ?>
  29.  
  30. <html>
  31. <head>
  32. <title>ADDING DATA</title>
  33. <style>
  34. label{display:inline-block;width:100px;margin-bottom:10px;}
  35. </style>
  36. </head>
  37. <body>
  38. <form method="post" action="book.php">
  39. <label>TITLE</label>
  40. <input type="text" name="title" />
  41. <br />
  42. <label>AUTHOR</label>
  43. <input type="text" name="author" />
  44. <br />
  45. <label>ACCOUNT NUMBER</label>
  46. <input type="text" name="accountnumber" />
  47. <br />
  48. <label>CALLNUMBER</label>
  49. <input type="text" name="callnumber" />
  50. <br />
  51. <input type="submit" value="Add Book">
  52. </form>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement