Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Adatbekérő</title>
- <meta charset = "UTF-8">
- </head>
- <body>
- <form id = "data" name = "data" method = "post" action = "#">
- Név: <input type = "text" name = "name"><br>
- Születési dátum: <input type = "date" name = "birthdate"><br>
- E-mail cím: <input type = "email" name = "email"><br>
- Erdeklődési kör (választható):<br>
- <input type="checkbox" name="interests[]" value="informatika">informatika<br>
- <input type="checkbox" name="interests[]" value="művészetek">művészetek<br>
- <input type="checkbox" name="interests[]" value="autók">autók<br>
- <input type="checkbox" name="interests[]" value="politika">politika<br>
- <input type="checkbox" name="interests[]" value="főzés">főzés<br>
- <input type = "submit" name = "send" value = "Küldés">
- </form>
- </body>
- </html>
- <?php
- if($_POST)
- {
- $link = mysqli_connect("127.0.0.1", "root", "", "asd");
- if (!$link) {
- echo "Hiba!";
- exit;
- }
- //print_r($_POST["interests"]);
- $name = mysqli_real_escape_string($link, $_POST["name"]);
- $birthdate = mysqli_real_escape_string($link, $_POST["birthdate"]);
- $email = mysqli_real_escape_string($link, $_POST["email"]);
- $interests = mysqli_real_escape_string($link, implode(",", $_POST["interests"]));
- $sql = "INSERT INTO people (name, birthdate, email, interests) VALUES ('$name','$birthdate','$email','$interests')";
- if(mysqli_query($link, $sql) === TRUE)
- {
- echo "Hozzáadva!";
- }
- echo "<table>";
- $sql = "SELECT * FROM people";
- if ($result = mysqli_query($link, $sql))
- {
- while ($row = mysqli_fetch_assoc($result))
- {
- echo "<tr>";
- echo "<td>" . $row["ID"] . "</td>";
- echo "<td>" . $row["name"] . "</td>";
- echo "<td>" . $row["birthdate"] . "</td>";
- echo "<td>" . $row["email"] . "</td>";
- echo "<td>" . $row["interests"] . "</td>";
- echo "<tr>";
- }
- mysqli_free_result($result);
- }
- echo "</table>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement