Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- </head>
- <body>
- <form>
- Előnév:
- <input type="text" name="input_eloneve">
- <br />
- Utónév:
- <input type="text" name="input_utoneve">
- <br />
- Mióta barátod?
- <input type="date" name="input_datum">
- <br />
- Közös érdeklődés:
- <textarea name="input_kozos_erdeklodes"></textarea>
- <br />
- <input type="hidden" name="action" value="felvesz_muvelet">
- <input type="submit" value="Felvétel">
- </form>
- <?php
- if(isset($_GET["action"]) and $_GET["action"]=="felvesz_muvelet"){
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "facebook";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "INSERT INTO
- `facebook`.`baratok`
- (
- `barat_eloneve`,
- `barat_utoneve`,
- `barat_datum`,
- `barat_kozos_erdeklodes`,
- `barat_aktivitas`
- )
- VALUES
- (
- '" . $_GET['input_eloneve'] . "',
- '" . $_GET['input_utoneve'] . "',
- '" . $_GET['input_datum'] . "',
- '" . $_GET['input_kozos_erdeklodes'] . "',
- 1
- );
- ";
- if(mysqli_query($conn, $sql)){
- echo "Sikeres barátfelvétel!";
- }else {
- echo "Sikertelen barátfelvétel!";
- echo $sql;
- }
- mysqli_close($conn);
- }
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "facebook";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM baratok";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- echo "<h3>" . $row["barat_eloneve"] . " " . $row["barat_utoneve"] . "</h3>";
- }
- } else {
- echo "0 results";
- }
- mysqli_close($conn);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement