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
6 changes: 6 additions & 0 deletions app/close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
session_start();

unset($_SESSION['userName']);
session_destroy();
header('Location: ../public/index.php ');
28 changes: 28 additions & 0 deletions app/validate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
session_start();

define("user", ["userName" => "admin", "password" => "admin"]);

if (isset($_SESSION['userName'])) {
$url = '../resources/views/panel.php';
header('Location: ' . $url);
exit();
} else if (isset($_POST['userName']) && isset($_POST['password'])) {
$userName = $_POST['userName'];
$password = $_POST['password'];

if ($userName === user["userName"] && $password === user["password"]) {
$_SESSION['password'] = $password;
$_SESSION['userName'] = $userName;
$url = '../resources/views/panel.php';
header('Location: ' . $url);
} else {

define("ERRORMSG", '<script language="javascript"> alert("Incorrect user or password");</script>');
setcookie("IncorrectLoginCookie", ERRORMSG, time() + 1, "/");
header('Location: ../public/index.php ');
exit();
}

exit();
};
27 changes: 19 additions & 8 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
<link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="./assets/css/cheatsheet.css">
</head>
<?php
session_start();

header('Location: ./public/index.php ');
?>

<body class="bg-light">

Expand Down Expand Up @@ -48,8 +53,9 @@
<a class="d-flex align-items-center" href="https://www.php.net/manual/es/book.session.php">Documentation</a>
</div>

<div>
<?php require_once("./workshop/1-introduction.php"); ?>
<!-- <div>
<?php // require_once("./workshop/1-introduction.php");
?>
</div>
</article>
<article class="my-3" id="create">
Expand All @@ -59,7 +65,8 @@
</div>

<div>
<?php require_once("./workshop/2-create.php"); ?>
<?php // require_once("./workshop/2-create.php");
?>
</div>
</article>
<article class="my-3" id="read">
Expand All @@ -69,7 +76,8 @@
</div>

<div>
<?php require_once("./workshop/3-read.php"); ?>
<?php // require_once("./workshop/3-read.php");
?>
</div>
</article>
<article class="my-3" id="modify">
Expand All @@ -79,7 +87,8 @@
</div>

<div>
<?php require_once("./workshop/4-modify.php"); ?>
<?php // require_once("./workshop/4-modify.php");
?>
</div>
</article>
<article class="my-3" id="destroy">
Expand All @@ -89,7 +98,8 @@
</div>

<div>
<?php require_once("./workshop/5-destroy.php"); ?>
<?php // require_once("./workshop/5-destroy.php");
?>
</div>
</article>
<article class="my-3" id="demo">
Expand All @@ -99,8 +109,9 @@
</div>

<div>
<?php require_once("./workshop/6-demo.php"); ?>
</div>
<?php // require_once("./workshop/6-demo.php");
?>
</div> -->
</article>
</section>
</div>
Expand Down
61 changes: 61 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!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>Index</title>
<link rel="stylesheet" href="../resources/styles.css">
</head>


<body>
<div id="header" class="header">
<div id="flex" class="flex">
<div id="box" class="box">
<div class="title">
<h1>PHP CHEAT SHEET</h1>
</div>
</div>
</div>
</div>
<div class="main">
<div id="flex" class="flex">
<div id="box" class="box">
<div class="title">
<h2>Login!!</h2>
</div>
<div class="info">

<form method="post" id="form" action="../app/validate.php">

<h4>User Name</h4>
<input type="text" id="userName" name="userName" required>
<h4>Password</h4>
<input type="password" id="password" name="password" required>

<div>
<input class="btn" type="submit" value="Login">
</div>
</form>

</div>
</div>
</div>
</div>
</body>
<?php
session_start();
if (isset($_COOKIE["NotLoggedCookie"])) {
echo $_COOKIE["NotLoggedCookie"];
unset($_COOKIE['NotLoggedCookie']);
setcookie('NotLoggedCookie', null, -1, '/');
} else if (isset($_COOKIE["IncorrectLoginCookie"])) {
echo $_COOKIE["IncorrectLoginCookie"];
unset($_COOKIE['IncorrectLoginCookie']);
setcookie('IncorrectLoginCookie', null, -1, '/');
}
?>

</html>
Binary file added resources/assets/img/aut.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
@import url("https://fonts.googleapis.com/css?family=Rajdhani:300,400,500,600,700");
@import url("https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i");
@import url("https://fonts.googleapis.com/css?family=Raleway:100,400,600,700,900&display=swap");

html {
font-family: Raleway;
scroll-behavior: smooth;
background-image: url("./assets/img/aut.gif");
background-repeat: no-repeat;
background-color: black;
background-size: cover;
}

.header .box {
min-height: 10vh;
}

.main {
margin: 10px 30px;
}

.userlogin .box {
margin: 0px 40px;
min-height: 3vh;
max-width: inherit;
justify-content: flex-end;
}
.flex {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
transition: all 0.7s;
}

.box {
display: flex;
flex-wrap: wrap;
max-width: 90%;
justify-content: space-around;
border-radius: 3%;
border: solid rgb(65, 12, 12) 2px;
text-align: center;
margin: 2% 1%;
padding: 1%;
min-height: 35vh;
background-color: rgba(119, 60, 37, 0.459);
}
.box .title {
color: rgb(221, 202, 118);
text-shadow: 1px 3px rgb(196, 120, 85);
min-width: 100%;
max-height: 10vh;
font-size: large;
z-index: 1;
}
.box .info {
color: rgb(221, 202, 118);

z-index: 1;
font-size: medium;
}
.box h3 {
font-family: monospace;
color: rgb(221, 202, 118);
text-align: left;
}
.btn {
outline: rgb(65, 12, 12) solid 1px;
color: rgb(221, 202, 118);
margin: 0px 20px;
background-color: rgba(119, 60, 37, 0.459);
padding: 0.5% 2%;
font-size: 0.7rem;
cursor: pointer;
text-align: center;

height: min-content;
}

.item {
padding: 0.6%;
border: solid rgb(221, 202, 118) 2px;
color: rgb(221, 202, 118);
text-shadow: 1px 3px rgb(196, 120, 85);
border-radius: 3%;
height: fit-content;
max-height: 5vh;
}

input[type="text"],
input[type="password"] {
color: white;
background-color: rgba(119, 60, 37, 0.459);
}
Loading