Guest User

Untitled

a guest
Jun 6th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4. $product = $_POST["product"];
  5. $quantity = intval($_POST["quantity"]);
  6.  
  7. $servername = "localhost";
  8. $username = "root";
  9. $password = "80";
  10. $dbname = "product_database";
  11.  
  12. // Create connection
  13. $conn = new mysqli($servername, $username, $password, $dbname);
  14. // Check connection
  15. if ($conn->connect_error) {
  16. die("Connection failed: " . $conn->connect_error);
  17. }
  18.  
  19. $stmt = $conn->prepare("INSERT INTO products (name, quantity) VALUES (?, ?)");
  20. $stmt->bind_param("si", $product, $quantity);
  21. $stmt->execute();
  22.  
  23. $stmt->close();
  24. $conn->close();
  25.  
  26. echo "<h1>New records created successfully</h1>";
  27. ?>
  28. Product: <?php echo $product; ?><br>
  29. Quantity: <?php echo $quantity; ?>
  30.  
  31. </body>
  32. </html>
Add Comment
Please, Sign In to add comment