This commit is contained in:
szabomarton 2025-01-23 11:49:34 +01:00
parent a5f8028b59
commit 6274dcb734
2 changed files with 76 additions and 0 deletions

57
20250123/feldolgozo.php Normal file
View File

@ -0,0 +1,57 @@
<?php
if($_SERVER["REQUEST_METHOD"] === "POST"){
if (
isset($_POST["nev"])
&& isset($_POST["email"])
&& !empty($_POST["nev"])
&& !empty($_POST["email"])){
$nev = $_POST["nev"];
$email = $_POST["email"];
$username = "root";
$password = "";
$serverName = "localhost";
$database = "alap";
$conn = new mysqli($serverName, $username, $password, $database);
$tableCreate = "CREATE TABLE IF NOT EXISTS alap.felhasznalo (
id INT AUTO_INCREMENT PRIMARY KEY,
nev VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL
);";
$beszuras = "INSERT INTO alap.felhasznalo (nev, email) VALUES
('". $nev."','".$email."');";
$lekerdezes = "SELECT * FROM alap.felhasznalo";
if ($conn->connect_error){
die("Kapcsolódási hiba: ".$conn->connect_error);
}
function futtatas($conn, $utasitas){
if($conn->query($utasitas)){
echo "GOOD";
} else {
echo $conn->error;
}
}
futtatas($conn, $tableCreate);
futtatas($conn, $beszuras);
$lekerdezes_eredmeny = $conn->query($lekerdezes);
if ($lekerdezes_eredmeny->num_rows > 0){
while ($sor = $lekerdezes_eredmeny->fetch_assoc()) {
echo "azonosító: ".$sor['id'].",Név: ".$sor['nev'].",Email:".$sor['email']."<br>";
}
} else {
echo "Nincs találat";
}
} else {
echo "Hiba történt, nem került adat betöltésre.";
}
}

19
20250123/form.php Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="feldolgozo.php" method="POST" target="_blank">
<label>Név:</label>
<input type="text" name="nev" required/>
<br>
<label>E-mail cím:</label>
<input type="email" name="email" required/>
<br>
<input type="submit" value="Küldés"/>
</form>
</body>
</html>