Advertisement
Guest User

asd

a guest
Apr 10th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. </head>
  6. <body>
  7.  
  8. <form>
  9. Előnév:
  10. <input type="text" name="input_eloneve">
  11. <br />
  12.  
  13. Utónév:
  14. <input type="text" name="input_utoneve">
  15. <br />
  16.  
  17. Mióta barátod?
  18. <input type="date" name="input_datum">
  19. <br />
  20.  
  21. Közös érdeklődés:
  22. <textarea name="input_kozos_erdeklodes"></textarea>
  23. <br />
  24.  
  25. <input type="hidden" name="action" value="felvesz_muvelet">
  26. <input type="submit" value="Felvétel">
  27. </form>
  28. <?php
  29.  
  30. if(isset($_GET["action"]) and $_GET["action"]=="felvesz_muvelet"){
  31. $servername = "localhost";
  32. $username = "root";
  33. $password = "";
  34. $dbname = "facebook";
  35.  
  36. // Create connection
  37. $conn = mysqli_connect($servername, $username, $password, $dbname);
  38. // Check connection
  39. if (!$conn) {
  40. die("Connection failed: " . mysqli_connect_error());
  41. }
  42.  
  43. $sql = "INSERT INTO
  44. `facebook`.`baratok`
  45. (
  46. `barat_eloneve`,
  47. `barat_utoneve`,
  48. `barat_datum`,
  49. `barat_kozos_erdeklodes`,
  50. `barat_aktivitas`
  51. )
  52. VALUES
  53. (
  54. '" . $_GET['input_eloneve'] . "',
  55. '" . $_GET['input_utoneve'] . "',
  56. '" . $_GET['input_datum'] . "',
  57. '" . $_GET['input_kozos_erdeklodes'] . "',
  58. 1
  59. );
  60. ";
  61.  
  62. if(mysqli_query($conn, $sql)){
  63. echo "Sikeres barátfelvétel!";
  64. }else {
  65. echo "Sikertelen barátfelvétel!";
  66. echo $sql;
  67. }
  68. mysqli_close($conn);
  69. }
  70.  
  71. $servername = "localhost";
  72. $username = "root";
  73. $password = "";
  74. $dbname = "facebook";
  75.  
  76. // Create connection
  77. $conn = mysqli_connect($servername, $username, $password, $dbname);
  78. // Check connection
  79. if (!$conn) {
  80. die("Connection failed: " . mysqli_connect_error());
  81. }
  82.  
  83. $sql = "SELECT * FROM baratok";
  84. $result = mysqli_query($conn, $sql);
  85.  
  86. if (mysqli_num_rows($result) > 0) {
  87. // output data of each row
  88. while($row = mysqli_fetch_assoc($result)) {
  89. echo "<h3>" . $row["barat_eloneve"] . " " . $row["barat_utoneve"] . "</h3>";
  90. }
  91. } else {
  92. echo "0 results";
  93. }
  94.  
  95. mysqli_close($conn);
  96. ?>
  97.  
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement