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
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</p>

> In this project you will learn how to explore the content of the variable $_SERVER which is injected to the running script, in it we can find information about the server environment and the client.
It has been interesting to know how a form is made in php. It was somewhat complex for me to understand the "session_start" since it gave me some problems at the beginning by not getting the correct info to take me to the next page.

## Index <!-- omit in toc -->

- [Requirements](#requirements)
- [Repository](#repository)
- [Technologies used](#technologies-used)
- [Project delivery](#project-delivery)
- [Resources](#resources)
Expand All @@ -20,18 +20,12 @@

- 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'>
- introduce Bootstrap in PHP.

## Technologies used

\* PHP
\* Bootstrap

## Project delivery

Expand Down
10 changes: 10 additions & 0 deletions close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

session_start();
unset($_SESSION);
session_destroy();
session_write_close();
header('Location: index.php');
exit;

?>
54 changes: 54 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="es">

<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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Php Form</title>
</head>

<body class="body">
<div class="container">

<h1>Log in</h1>


<form id="regiration_form" action="validate.php" method="post">
<fieldset>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="user" name="user" placeholder="Username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="pass" placeholder="Password">
</div>
<p>
<?php

if (isset($_GET["error"])) {
if ($_GET["error"] === "error") {
echo "Your username or pass is wrong.";
} else if ($_GET["error"] === "userempty") {
echo "Your username is empty.";
} else if ($_GET["error"] === "passempty") {
echo "Your pass is empty.";
}
;
}

?>
</p>
<br>
<input type="submit" class="next btn btn-info" value="Sing In" />
</fieldset>
</form>
</div>
</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();

?>

<!DOCTYPE html>
<html lang="es">

<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="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Wellcome Javier</title>
</head>


<body class="body">
<div class="container">
<h1>Account setting</h1><br>
<div class="form-group">
<a href="close_session.php" class="next btn btn-info" role="button">Logout</a>
</div>
</div>
</body>

</html>
12 changes: 12 additions & 0 deletions server_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>";

?>
8 changes: 8 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
p {
color: red;
}

.body {
background-color: rgb(98, 98, 98);
color:white;
}
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();

$userdb = "Javier";
$passdb = "121212";

if($userdb===$_REQUEST["user"] && $passdb===$_REQUEST["pass"]){
header("Location: panel.php");
} else if($_REQUEST["user"] === ""){
header("Location: index.php?error=userempty");
} else if($_REQUEST["pass"] === ""){
header("Location: index.php?error=passempty");
} else {
header("Location: index.php?error=error");
}

?>