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
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`#php` `#server` `#master-in-software-development`

# PHP Server Environment <!-- omit in toc -->
# PHP Server Environment

<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0-blue.svg?cacheSeconds=2592000" />
Expand All @@ -11,33 +11,18 @@
## Index <!-- omit in toc -->

- [Requirements](#requirements)
- [Repository](#repository)
- [Technologies used](#technologies-used)
- [Project delivery](#project-delivery)
- [Resources](#resources)

## Requirements

- Learn how to use the $_SERVER
- Understand what a server-side language is and what it is used for

## Repository

First of all you must fork this project into your GitHub account.

To create a fork on GitHub is as easy as clicking the “fork” button on the repository page.

<img src="https://docs.github.com/assets/cb-23088/images/help/repository/fork_button.png" alt="Fork on GitHub" width='450'>

## Technologies used

\* PHP

## Project delivery

To deliver this project you must send a Pull Request as explained in the Students Handbook. Remember that the PR title must be with the format
- Solution: + NAME AND SURNAME or TEAM NAMES AND SURNAMES.
- For example: "Solution: Josep Riera", "Solution: Josep Riera, Toni Suárez, Marta Vázquez"

## Resources

Expand Down
Binary file added assets/5minRelaxMusic.mp3
Binary file not shown.
Binary file added assets/Oriental Japanese Dojo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/door.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/tori.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
session_start();
$_SESSION=[];
session_destroy();
header("location: index.php");
?>



3 changes: 3 additions & 0 deletions exercises/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?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

print_r($_SERVER);

?>
11 changes: 11 additions & 0 deletions exercises/session_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

session_start();

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

print_r($_SESSION);

?>
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">
<title>Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="initialPage">
<form action="validate.php" method="post">
<div class="login">
<label for="userName">
User name:
<input type="text" name="userName" class="userName">
</label>
<label for="password">
Password:
<input type="password" name="password" class="password">
</label>
<?php
if(isset($_GET["error"])){
echo "<div class='invalid'>Invalid username or password</div>";
}
?>
<button type="submit" class="btnSubmit">Enter the side</button>
</div>
</form>


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

<?php
session_start();
if(!isset ($_SESSION["userName"])) {
header("location: index.php?errorLogin");
}
?>


<!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>
<link rel="stylesheet" href="style.css">
</head>
<body class="tori">
<div class="logout">
<a href="close_session.php"><button class="btnPanel">Logout</button></a>
</div>
<div class="welcome">
<h1>BIENVENIDO</h1>
<p>Tómate 5 minutos para descansar</p>
</div>
<audio class ="control" controls autoplay loop>
<source src="assets/5minRelaxMusic.mp3" type="audio/mp3">
</audio>
</body>
</html>
79 changes: 79 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}


.initialPage {
background-image: url(assets/door.jpg);
background-repeat: no-repeat;
background-size: cover;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.invalid {
color: red;
font-size: 18px;
display:flex;
flex-direction: column;
align-items: center;
}

.login {
display:flex;
flex-direction: column;
align-items: center;
}

.btnSubmit {
width: 6em;
margin: 2em;
border-radius: 20px;
}

label {
color: yellow;
display: flex;
flex-direction: column;
justify-content: space-between;
}

.welcome {
color:yellow;
display:flex;
flex-direction:column;
align-items: center;
margin-top: 4em;
font-size: 20px;
}

.control {
/* height: 100vh; */
position: absolute;
bottom: 0;
opacity: 0.1;
}

.control:hover {
opacity: 1;
transition: 3s;
}

.tori {
background-image: url(assets/tori.jpg);
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}

.logout {
display: flex;
justify-content: end;
width: 100%;
border-radius: 20px;
}

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

$correctUserName = "Alvaro";
$correctPassword = "123123";


if($_POST["userName"] === $correctUserName && $_POST["password"] === $correctPassword) {
session_start();
$_SESSION["userName"]=$_POST["userName"];
header("location: panel.php");
}else{
header("location: index.php?error=loginFailed");
}

?>