Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Adatbekérő</title>
  4. <meta charset = "UTF-8">
  5. </head>
  6. <body>
  7. <form id = "data" name = "data" method = "post" action = "#">
  8. Név: <input type = "text" name = "name"><br>
  9. Születési dátum: <input type = "date" name = "birthdate"><br>
  10. E-mail cím: <input type = "email" name = "email"><br>
  11. Erdeklődési kör (választható):<br>
  12. <input type="checkbox" name="interests[]" value="informatika">informatika<br>
  13. <input type="checkbox" name="interests[]" value="művészetek">művészetek<br>
  14. <input type="checkbox" name="interests[]" value="autók">autók<br>
  15. <input type="checkbox" name="interests[]" value="politika">politika<br>
  16. <input type="checkbox" name="interests[]" value="főzés">főzés<br>
  17. <input type = "submit" name = "send" value = "Küldés">
  18. </form>
  19. </body>
  20. </html>
  21.  
  22. <?php
  23. if($_POST)
  24. {
  25. $link = mysqli_connect("127.0.0.1", "root", "", "asd");
  26.  
  27. if (!$link) {
  28. echo "Hiba!";
  29. exit;
  30. }
  31.  
  32. //print_r($_POST["interests"]);
  33.  
  34. $name = mysqli_real_escape_string($link, $_POST["name"]);
  35. $birthdate = mysqli_real_escape_string($link, $_POST["birthdate"]);
  36. $email = mysqli_real_escape_string($link, $_POST["email"]);
  37. $interests = mysqli_real_escape_string($link, implode(",", $_POST["interests"]));
  38. $sql = "INSERT INTO people (name, birthdate, email, interests) VALUES ('$name','$birthdate','$email','$interests')";
  39. if(mysqli_query($link, $sql) === TRUE)
  40. {
  41. echo "Hozzáadva!";
  42. }
  43.  
  44. echo "<table>";
  45. $sql = "SELECT * FROM people";
  46. if ($result = mysqli_query($link, $sql))
  47. {
  48. while ($row = mysqli_fetch_assoc($result))
  49. {
  50. echo "<tr>";
  51. echo "<td>" . $row["ID"] . "</td>";
  52. echo "<td>" . $row["name"] . "</td>";
  53. echo "<td>" . $row["birthdate"] . "</td>";
  54. echo "<td>" . $row["email"] . "</td>";
  55. echo "<td>" . $row["interests"] . "</td>";
  56. echo "<tr>";
  57. }
  58. mysqli_free_result($result);
  59. }
  60. echo "</table>";
  61. }
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement