Guest User

Untitled

a guest
Sep 5th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <form action="insert.php" method="POST">
  2. Firstname: <input type="text" name="fname" required /><br>
  3. Lastname: <input type="text" name="lname" require /><br>
  4. <input type="submit" />
  5. </form>
  6.  
  7. <form action="insert.php" method="POST">
  8. Firstname: <ons-input type="text" name="lname" required />
  9. Lastname: <ons-input type="text" name="lname" required />
  10. <input type="submit" />
  11. </form>
  12.  
  13. <?php
  14. $servername = "localhost";
  15. $username = "root";
  16. $password = "";
  17. $dbname = "testdb";
  18.  
  19.  
  20. $conn = new mysqli($servername, $username, $password, $dbname);
  21.  
  22. if ($conn->connect_error) {
  23. die("Connection failed: " . $conn->connect_error);
  24. }
  25.  
  26. $sql = "INSERT INTO exampledb (fname, lname)
  27. VALUES ('".$_POST["fname"]."','".$_POST["lname"]."')";
  28.  
  29. if ($conn->multi_query($sql) === TRUE) {
  30. echo "New records created successfully";
  31. } else {
  32. echo "Error: " . $sql . "<br>" . $conn->error;
  33. }
  34.  
  35. $conn->close();
  36. ?>
Add Comment
Please, Sign In to add comment