Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="insert.php" method="POST">
- Firstname: <input type="text" name="fname" required /><br>
- Lastname: <input type="text" name="lname" require /><br>
- <input type="submit" />
- </form>
- <form action="insert.php" method="POST">
- Firstname: <ons-input type="text" name="lname" required />
- Lastname: <ons-input type="text" name="lname" required />
- <input type="submit" />
- </form>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "testdb";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "INSERT INTO exampledb (fname, lname)
- VALUES ('".$_POST["fname"]."','".$_POST["lname"]."')";
- if ($conn->multi_query($sql) === TRUE) {
- echo "New records created successfully";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Add Comment
Please, Sign In to add comment