Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. // Our database connection
  4. $mysqli = mysqli_connect("localhost", "root", null, "lesson_03_php");
  5. var_dump($_POST);
  6.  
  7. $sql="INSERT into countries(
  8. name,
  9. description,
  10. population
  11. )values(
  12. ' {$_POST['name']}',
  13. '{$_POST['description']}',
  14. {$_POST['population']}
  15. )";
  16.  
  17. //QUery our database providing our connection and our sql
  18. $res = mysqli_query($conn, $sql);
  19.  
  20. //Perform some derpy error handling
  21.  
  22.  
  23. ?>
  24.  
  25. <!DOCTYPE html>
  26. <head>
  27. <title>Adding Countries</title>
  28. </head>
  29.  
  30. <body>
  31. <!-- The form for creating a new country -->
  32. <form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
  33. <div>
  34. <label>Country Name:</label>
  35. <input name="name">
  36. </div>
  37. <div>
  38. <label>Country Description:</label>
  39. <textarea name="description"></textarea>
  40. </div>
  41. <div>
  42. <label>Country Population:</label>
  43. <input name="population" type="number">
  44. </div>
  45.  
  46. <button type="submit">Create</button>
  47. </form>
  48. </body>
  49. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement