Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions close-seassion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
if(isset($_REQUEST["log-out"]) && $_SESSION["id"] == $Id){
header("location: index.php");
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(),'', time(),
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
session_destroy();
}
?>
48 changes: 48 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>
</head>
<body>
<?php
if(isset($_GET["private-zone"])){
echo "<div class= 'div-private-zone'>
<h2>Be careful, you are trying to enter to area 51</h2>
<p>Try again soldier</p>
</div>";
}
?>

<div class="registration-panel">
<form class="form-registration" action="validate.php" method="POST">
<label>Id
<input type="text" name="id" placeholder="***********">
</label>

<br>
<label>Password
<input type="password" name="id-pass" placeholder="***********">
</label>

<br>

<?php

if(isset($_GET["error-area"])){
echo "<div class= 'error-area'
<h2>Be careful, your conection is wrong to enter to area 51</h2>
<p>Try again sir</p>
</div>";
}
?>
<button type="submit" class="log-in">Login</button>
</form>
</div>

</body>
</html>
24 changes: 24 additions & 0 deletions panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
session_start();
if (!isset($_SESSION["id"]))
header("Location: index.php?private-zone");
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>
</head>
<body>
<h1>Welcome to area 51</h1>
<br>
<form action="close-seassion.php" method="GET">
<button type="input" name="log-out" >Logout</button>

</form>
</body>
</html>
5 changes: 5 additions & 0 deletions php-info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

phpinfo();

?>
16 changes: 16 additions & 0 deletions validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$Id = $_REQUEST["id"];
$password = $_REQUEST["id-pass"];
$correctId = "1234";
$correctPw = "4321";

if($Id === $correctId && $password === $correctPw){
session_start();
$_SESSION["id"] = $Id;
header("Location: panel.php");
} else{
header("Location: index.php?error-area=incorrect");
}

?>