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
Binary file added assets/backgroundphp.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

session_start();
session_destroy();
unset($_SESSION['username']);

unset($_COOKIE['sessionOver']);
setcookie('sessionOver', null, time()-2480, '/');

header('location: index.php');

?>

32 changes: 32 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!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" >
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<?php

session_start();


if (isset($_SESSION['logged-in'])) {
header('Location: panel.php');
exit();
}
?>

<div class="registration">
<form class="form" action='validate.php' method='POST'>
<label class="label"for="Name">Username</label><br>
<input type='text' name='user' required> <br>
<label class="label"for="Name">Password</label> <br>
<input type='password' name='password' required> <br>
<button type='submit' class="btn">Log in</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["user"]))header("Location: index.php");


?>

<!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">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>

<div class="login">
<h1> You are logged in </h1>
<a class="sign-out" href="close_session.php"> SIGN OUT </a>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

phpinfo();

?>
5 changes: 5 additions & 0 deletions server_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
echo "<pre>";
print_r($_SERVER);
echo "<\pre>";
?>
10 changes: 10 additions & 0 deletions sessions_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
session_start();

$_SESSION['browser'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";
?>
76 changes: 76 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
body{
background: url("assets/backgroundphp.jpg")
}

.registration{
width: 20%;
margin: 200px auto;
padding: 20px;
border-radius: 10px;
border: 2px solid black;
background: rgba(235, 222, 236, 0.374);
font-family: fantasy;

.form input{
width: 95%;
margin:0 auto;
border-radius: 5px;
border: 1px solid grey;
margin-bottom: 15px;
height: 2rem;
margin-top: 5px;
}

.form button{
margin: 0 auto;
display: block;
background: rgb(6, 40, 152);
color: white;
padding: 10px 30px;
border-radius: 5px;
border: 1px solid rgb(6, 40, 152);
margin-top: 10px;
font-weight: bold;
cursor: pointer;
}

.form label{

font-size: 20px;

}

.login{
width: 20%;
margin: 200px auto;
padding: 20px;
border-radius: 10px;
border: 2px solid black;
background: rgba(235, 222, 236, 0.374);
}

.login h1{
text-align: center;

}

.sign-out{
margin: 0 auto;
display: block;
background: rgb(6, 40, 152);
color: white;
padding: 10px 30px;
border-radius: 5px;
border: 1px solid rgb(6, 40, 152);
margin-top: 10px;
font-weight: bold;
width: 30%;
text-align: center;
cursor: pointer;

}


a:link, a:visited, a:active {
text-decoration:none;
}
18 changes: 18 additions & 0 deletions validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
session_start();
$username= '[email protected]';
$password= '123456';

echo '<pre>';
print_r($_REQUEST);
echo '</pre>';

if($username===$_REQUEST['user'] && $password===$_REQUEST['password']){
$_SESSION['user'] = $username;
header('Location: panel.php');
}else {
header('Location: index.php');
echo 'You are not logged';
}

?>