Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //HTML
- <!DOCTYPE html>
- <html>
- <head>
- </head>
- <body>
- <form action="insertData.php" method="post">
- name: <input type="varchar" name="name" method="post"><br>
- category: <input type="varchar" name="category"method="post"><br>
- price: <input type="float" name="price"method="post"><br>
- quantity: <input type="int" name="quantity"method="post"><br>
- checkdate: <input type="date" name="checkdate"method="post"><br>
- <input type="submit" value="submit">
- </form>
- </body>
- </html>
- //PHP
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "cs230";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = $conn->prepare("INSERT INTO stock (name, catagory, price, quantity, checkdate) VALUES (? ,?, ?, ?, ?)");
- $sql->bind_param("ssdii",$_POST['name'], $_POST['category'],$_POST['price'],$_POST['quantity'],$_POST['checkdate']);
- $sql->execute();
- mysqli_close($conn);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement