Backend/20241205/func.php

66 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2024-12-05 10:59:42 +00:00
<?php
$title = "Cím";
2024-12-09 13:52:37 +00:00
if (!isset($_SESSION["islogin"])){
$_SESSION["nev"] = "Vendég József";
$_SESSION["id"] = 9999;
$_SESSION["islogin"] = false;
}
//bejelentkezés vizsgálata
if (isset($_POST["lemail"])){
$lemail = $_POST["lemail"];
$sql = "SELECT * FROM felh WHERE email='".$lemail."'";
$result = $conn->query($sql);
if ($result->num_rows > 0){
$row = $result->fetch_object();
$_SESSION["islogin"] = true;
$_SESSION["nev"] = $row->nev;
$_SESSION["id"] = $row->uid;
$_SESSION["email"] = $row->email;
}
}
if ($_SESSION["islogin"]){
$_SESSION["email"] = "valamiemail";
} else {
$_SESSION["email"] = "";
}
2024-12-05 10:59:42 +00:00
if(isset($_POST["uzenet"])){
2024-12-09 13:52:37 +00:00
//echo "Az üzeneted: ".$_POST["uzenet"];
//$nev = $_POST["nev"];
$id = $_SESSION["id"];
//$email = $_POST["email"];
$uzenet = $_POST["uzenet"];
//$ido = date()
$sql = "INSERT INTO messages (uid, msg, status) VALUES (?,?,1)";
$param = $conn->prepare($sql);
$param->bind_param("is",$id, $uzenet);
if ($param->execute()){
echo "Sikeres üzenetmentés";
} else {
echo "Sikertelen üzenetmentés: ".$param->error;
}
$param->close();
}
$vendegkonyv = "";
$sql = "SELECT * from messages
INNER JOIN felh ON felh.uid = messages.uid
ORDER BY crdate DESC";
$result = $conn->query($sql);
if ($result->num_rows > 0){
$row = $result->fetch_object();
$vendegkonyv = "<h4> ". $row->name ." bejegyzése </h4> ";
$vendegkonyv .= "<p> ". $row->msg ."</p> ";
$vendegkonyv .= "<p><i> ". $row->crdate ."</i></p>";
} else {
echo "Nincs bejegyzés a vendégkönyvben.";
}