57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?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.";
|
|
}
|
|
} |