Advertisement
Guest User

Untitled

a guest
Feb 16th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password= "";
  5. $dbname = "inventory";
  6.  
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8.  
  9. if($conn->connect_error){
  10. die("Connection Failed:" . $conn->connect_error);
  11. }
  12.  
  13. $bookid = $_POST['bookid'];
  14. $title = $_POST['title'];
  15. $author = $_POST['author'];
  16. $accountnumber = $_POST['accountnumber'];
  17. $callnumber = $_POST['callnumber'];
  18.  
  19.  
  20. $sql = "INSERT INTO data (bookid,title,author,accountnumber,callnumber,) VALUES ('$bookid', $title','$author',
  21. '$accountnumber','$callnumber')";
  22.  
  23. if ($conn->query($sql) === TRUE) {
  24. $_session['comment']="Adding a new record successfully";
  25. header("Location:book.php");
  26. //echo "New record added successfully";
  27. } else{
  28. echo "Error: " .$sql . "<br>" . $conn->error;
  29. }
  30. $conn->close();
  31. ?>
  32. <!DOCTYPE html>
  33. <html>
  34. <head>
  35. <title>ADDING DATA</title>
  36. </head>
  37. <body>
  38. <form name="login" method="POST" action="book.php"><center>
  39. *ADD A NEW DATA*<br/>
  40. <a class='pull-left' href='home.php' style='text-decoration:none;'>back</a><br><br>
  41. TITLE: <input type= "text" placeholder ="Enter your name" name = "title" required><br/>
  42. AUTHOR: <input type= "text" placeholder ="Enter your address" name = "Author" required><br/>
  43. ACCOUNT NUMBER: <input type= "text" placeholder ="Enter your course" name = "AccountNumber" required><br/>
  44. CALL NUMBER: <input type= "text" placeholder ="Enter your birthdate" name = "CallNumber" required><br/>
  45. <input type= "submit" value = "ADD"></center>
  46. </body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement