I did some homework

This commit is contained in:
Digi 2024-09-18 20:24:12 +02:00
parent dc5ff7ddad
commit 6ebd347e44
9 changed files with 111 additions and 0 deletions

3
20240918_gyak/footer.php Normal file
View File

@ -0,0 +1,3 @@
<footer>
MADE BY DIGI (c) 2024
</footer>

View File

@ -0,0 +1,13 @@
<?php include 'header.php' ?>
<?php include 'isloggedin.php' ?>
<body>
<?php
if (!$isloggedin) {
require 'login.php';
} else {
require 'loggedin.php';
}
?>
<?php include 'footer.php' ?>
</body>
</html>

12
20240918_gyak/header.php Normal file
View File

@ -0,0 +1,12 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>PHP</title>
</head>

36
20240918_gyak/index.php Normal file
View File

@ -0,0 +1,36 @@
<?php
session_start();
?>
<!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>
<?php
//echo $_POST['name'];
setcookie("suti", "Digi", time() - 86400);
$_SESSION['username'] = "digivagyok";
echo $_SESSION['username'];
if (!isset($_SESSION['username'])){
echo "You are not logged in";
} else {
echo "You are logged in";
}
?>
<form method="POST">
<input type="hidden" name="name" value="Digi">
<button type="submit">PRESS ME!</button>
</form>
<a href="second.php">ASD</a>
</body>
</html>

View File

@ -0,0 +1,7 @@
<?php
$isloggedin = false;
if (isset($_POST['username']) && isset($_POST['password'])){
$isloggedin = true;
}
?>

View File

@ -0,0 +1,7 @@
<h1>
<?php
echo "Üdvözöllek: ".$_POST['username'];
?>
</h1>

5
20240918_gyak/login.php Normal file
View File

@ -0,0 +1,5 @@
<form method="POST">
Felhasználónév: <input type="text", name="username", value=""><br>
Jelszó: <input type="password", name="password", value=""><br>
<button type="submit">Bejelentkezés</button>
</form>

16
20240918_gyak/second.php Normal file
View File

@ -0,0 +1,16 @@
<?php
session_start();
?>
<!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>
<?php
echo $_SESSION['username'];
?>
</body>
</html>

12
20240918_gyak/style.css Normal file
View File

@ -0,0 +1,12 @@
body{
background-color: aqua;
color: blueviolet;
font-size: large;
}
footer{
background-color: black;
width: 100%;
position: absolute;
bottom: 3px;
}