added orai

This commit is contained in:
szabomarton 2024-10-15 07:51:06 +02:00
parent 8f5e76664e
commit 62a2e4cf1b
2 changed files with 73 additions and 0 deletions

38
20241014/func.php Normal file
View File

@ -0,0 +1,38 @@
<?php
function isSubmit(){
if (!isset($_POST)){
return false;
} else{
if (!isset($_POST["loginname"]) || strlen($_POST["loginname"]) < 4){
return false;
} else if (!isset($_POST["pwd"]) || strlen($_POST["pwd"]) < 4){
return false;
} else{
return true;
}
}
}
function checklogin(){
$jopwd = "alma";
$jouser = "user";
if ($_POST["loginname"] == $jouser && $_POST["pwd"] == $jopwd){
$_SESSION["isloggedin"] = 1;
$_SESSION["uname"] = $_POST["loginname"];
} else{
$_SESSION["isloggedin"] = 0;
return false;
}
}
function isLoggedIn(){
if ($_SESSION["isloggedin"] == 1){
return true;
} else{
return false;
}
}

35
20241014/index.php Normal file
View File

@ -0,0 +1,35 @@
<?php
session_start();
include("func.php");
if (isSubmit()){
if(checklogin()){
echo "sikeres bejelentkezés";
} else {
echo "bejelentkezesi hiba";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Munkamenet</title>
</head>
<body>
<?php
if (!isLoggedIn()){
?>
<h1>Bejelentkezés</h1>
<form action="#" method="POST">
Név: <input type="text" name="loginname"> <br>
Jelszó: <input type="password" name="pwd"> <br>
<button type="submit">OK</button>
</form>
<?php
}
?>
</body>
</html>