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

session_start();
session_destroy();
header('Location: index.php');
exit;

?>
31 changes: 31 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!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">
<style>
@import url('https://fonts.googleapis.com/css2?family=Caveat&display=swap');
</style>
</head>
<body>
<?php
if (isset($_GET["error"]))
echo '<div class="alert alert-dismissible alert-warning">
<h4 class="alert-heading">Warning!</h4>
<p class="mb-0">You have not logged in<a href="#" class="alert-link"></a></p>
</div>';
?>

<div>
<form action="validate.php" method="POST">
<label for="username">Username</label>
<input type="text" name="user" required>
<label for="password">Password</label>
<input type="password" name="password" required>
<button type="submit" class="btn">Log in</button>
</div>

</body>
</html>
26 changes: 26 additions & 0 deletions panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
session_start();
if (!isset($_SESSION["user"])) {
header("Location: index.php?error=privatezone");
}
?>


<!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">
<style>
@import url('https://fonts.googleapis.com/css2?family=Caveat&display=swap');
</style>

<title>Panel</title>
</head>
<body>
<h1>You're In!</h1>
<a href="close_session.php" class="btn btn-link">Logout</a>
</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();

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

?>
23 changes: 23 additions & 0 deletions session_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
session_start();

$_SESSION['browser'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();
echo '<pre>';
print_r($_SESSION);
echo '</pre>';


$inipath = php_ini_loaded_file();

if ($inipath) {
echo 'Loaded php.ini: ' . $inipath;
} else {
echo 'A php.ini file is not loaded';
}




?>
36 changes: 36 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@


*{
font-family: 'Caveat', cursive;
}

body {
background-image: url("assets/img/foto.jpeg");
background-size: cover;
}

form {
font-size: 20px;
min-width: 330px;
max-width: 330px;
display: flex;
flex-direction: column;
margin: 150px auto;
align-items: center;
/* gap: 5px; */
border: 5px solid black;
text-align: center;
background-color: rgba(120, 140, 140, 0.534);

}
form h3{

margin-top: 15px;
}
form input{
margin: 0;
}
.btn{
font-size: 20px;
margin-bottom: 20px;
}
22 changes: 22 additions & 0 deletions validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
session_start();
$username = "berta";
$password = "12345";

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?error=You've to insert a correct username");
echo "You're not logged";
}


?>