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
135 changes: 135 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
color: #c9dff6;
}

.container-login {
height: 100vh;
width: 100vw;
display: flex;
flex-direction: row;
}

.img-login {
width: 50vw;
background-image: url("../img/esma-Phaz7JBtSWE-unsplash.jpg");
background-size: cover;
}

.container-form-login {
width: 50vw;
height: 100vh;
background-color: #476972;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.form-login {
width: 35vw;
height: 85vh;
padding: 5em;

display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: space-around;
}

.form-login h2 {
margin-bottom: 1.5em;
}

.form-login input {
background-color: #476972;
height: 3em;
width: 20em;
border-color: #c9dff6;
font-size: 1em;
padding: 1em;
}

input:focus {
background-color: #c9dff6;
color: #242829;
outline: none;
}

input:-webkit-autofill {
-webkit-text-fill-color: #c9dff6;
-webkit-box-shadow: 0 0 0px 1000px #476972 inset;
}

.form-login label {
color: #c9dff6;
font-size: 1em;
}

button {
height: 3em;
width: 20em;
margin-top: 2em;
background-color: #c9dff6;
border-color: #c9dff6;
color: #242829;
font-size: 1em;
cursor: pointer;
}

.body-panel-page {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #476972;
}

.body-panel-page h2 {
font-size: 50px;
margin-bottom: 1em;
}

.body-panel-page div {
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-image: url("../img/esma-Phaz7JBtSWE-unsplash.jpg");
background-size: cover;
}

.body-panel-page div h2 {
color: #242829;
text-shadow: 1px 1px 1px #476972;
}

.body-panel-page div button {
background-color: #242829;
color: #8f9ead;
border-color: #242829;
}

.error-invalid-user {
width: 90vw;
height: 4.5em;
top: 10px;
position: fixed;
background-color: #c9dff6af;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}

.error-invalid-user h3 {
color: #242829;
font-size: 45px;
}
Binary file added assets/img/esma-Phaz7JBtSWE-unsplash.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
session_start();

if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
}

session_destroy();

header("Location: index.php");
2 changes: 2 additions & 0 deletions exercises/info.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
phpinfo();
5 changes: 5 additions & 0 deletions exercises/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>';
12 changes: 12 additions & 0 deletions exercises/session_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
session_start();

$_SESSION['browser'] = $_SERVER['HTTP_USER_AGENT'];
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['time'] = time();

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

echo php_ini_loaded_file();
43 changes: 43 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!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>Login Page</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>

<body>
<?php
session_start();

if (count($_SESSION)) {
header("Location: panel.php");
} else if (isset($_GET["error"])) {
echo "<div class='error-invalid-user'><h3>Enter a valid email and password!</h3></div>";
}

?>
<div class="container-login">
<div class="img-login"></div>
<div class="container-form-login">
<form class="form-login" action="validate.php" method="POST">

<h2>Login</h2>

<label for="email">Email:</label>
<input type="email" name="email" id="email">

<label for="password">Pasword:</label>
<input type="password" name="password" id="password">

<button type="submit">Submit</button>

</form>
</div>
</div>
</body>

</html>
34 changes: 34 additions & 0 deletions panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!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>User Page</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>

<body class="body-panel-page">

<?php
session_start();

if (isset($_SESSION['email'])) {
echo "<h2>Welcome, " . $_SESSION['email'] . "!</h2>";
echo "<form action='close_session.php' method='POST'>";
echo "<button type='submit'>Logout</button>";
echo "</form>";
} else {
echo "<div>";
echo "<h2>It is a private section...</h2>";
echo "<form action='close_session.php' method='POST'>";
echo "<button type='submit'>Return</button>";
echo "</form>";
echo "</div>";
}
?>

</body>

</html>
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();

$email = "imarti.teixido@gmail.com";
$password = "12345";



if ($_POST['email'] === $email && $_POST['password'] === $password) {
if (!count($_SESSION)) {
$_SESSION['email'] = $_POST['email'];
$_SESSION['password'] = $_POST['password'];
}
header("Location: panel.php");
} else {
header("Location: index.php?error=invalidUserPassword");
}