Advertisement
Guest User

Untitled

a guest
Mar 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. //HTML
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. </head>
  7. <body>
  8. <form action="insertData.php" method="post">
  9. name: <input type="varchar" name="name" method="post"><br>
  10. category: <input type="varchar" name="category"method="post"><br>
  11. price: <input type="float" name="price"method="post"><br>
  12. quantity: <input type="int" name="quantity"method="post"><br>
  13. checkdate: <input type="date" name="checkdate"method="post"><br>
  14. <input type="submit" value="submit">
  15. </form>
  16. </body>
  17. </html>
  18.  
  19.  
  20. //PHP
  21.  
  22. <?php
  23. $servername = "localhost";
  24. $username = "root";
  25. $password = "";
  26. $dbname = "cs230";
  27.  
  28. // Create connection
  29. $conn = mysqli_connect($servername, $username, $password, $dbname);
  30. // Check connection
  31. if (!$conn) {
  32. die("Connection failed: " . mysqli_connect_error());
  33. }
  34.  
  35. $sql = $conn->prepare("INSERT INTO stock (name, catagory, price, quantity, checkdate) VALUES (? ,?, ?, ?, ?)");
  36. $sql->bind_param("ssdii",$_POST['name'], $_POST['category'],$_POST['price'],$_POST['quantity'],$_POST['checkdate']);
  37. $sql->execute();
  38.  
  39. mysqli_close($conn);
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement