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 Assets/imagen-principal.png
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/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions close_session.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
session_start();
session_destroy();
header('Location: index.php');
?>
52 changes: 52 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

<!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 href="style.css" rel="stylesheet" type="text/css">
</head>

<body class="pagina-login">
<div class="container">
<form action="validate.php" method="POST" class="formulario">
<label for="username" class="username-label">
Username:
<input type="text" name="username" id="username">
</label>
<label for="password" class="password-label">
Password:

<input type="password" name="password" id="password">
</label>
<input type="submit" name="finalizar" id="submit">
<div class="errores">
<p>
<?php
session_start();
if (isset($_SESSION['errorVacio'])) {
echo $_SESSION['errorVacio'];
session_destroy();
}
if (isset($_SESSION['errorSession'])) {
echo $_SESSION['errorSession'];
session_destroy();
}
if(isset($_SESSION['username'])){
header("Location: panel.php");
}


?>
</p>
</div>

</form>
</div>

</body>

</html>
47 changes: 47 additions & 0 deletions panel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!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>Logueado</title>
<link href="principalStyle.css" rel="stylesheet" type="text/css">
<script src="script.js" defer></script>
</head>

<body>

<div class="menu">
<img src="Assets/logo.png">
<div class="account">Account</div>

</div>
<div class="menu-account">
<?php
session_start();
if(!isset($_SESSION['username'])){
header("Location: index.php");
}
echo "<p><b>Username:</b> ". $_SESSION['username']."</p>";
echo "<p><b>Password:</b> ".$_SESSION['password']."</p>";
?>
<p class="unlogin"><b>Unlogin</b></p>
</div>


<session class="container">
<h1>Find Your City</h1>
<div class="content">
<input type="text" placeholder="What are you search?">
<input type="text" placeholder="location">
<select name="categories">
<option >All Categories</option>
</select>
<button type="button">Search</button>
</div>

</session>
</body>

</html>
106 changes: 106 additions & 0 deletions principalStyle.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
body {
width: 100%;
height: 100%;
background-image: url("Assets/imagen-principal.png");
background-size: cover;
place-items: center;
display: flex;
justify-content: center;

}

.menu {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
height: 12vh;
background-color: blue;
margin-top: -1.5%;
margin-left: -1.5%;
}

.menu img {
width: 5%;
height: 70%;
margin-left: 2%;
margin-top: 1%;
}


.account {
color: white;
margin-right: 3%;
margin-top: 1%;
cursor: pointer;
}

.account:hover {
background-color: black;
color: aqua;
}

.menu-account {
display: none;

}

.menu-account_show {
background-color: black;
color: white;
width: 10%;
margin-bottom: -10%;
margin-left: 90%;
display: block;
position: absolute;
z-index: 0;
}

.menu-account p:hover {
background-color: red;
}

.container {
width: 100%;
height: 100%;
place-items: center;
display: flex;
flex-direction: column;
justify-content: center;
position: absolute;
margin-bottom: -30%;
z-index: -1;
}

.container h1 {
font: bold 80px/1 arial;
text-transform: uppercase;
color: #c69c1e;
text-shadow: 0 12px 0 #41330a;
font-size: 100px;

}

.content {
width: 80%;
height: 20%;
}

input {
width: 31%;
height: 100%;
text-align: center;
}

select {
width: 31%;
height: 100%;
text-align: center;
}

button {
width: 31%;
height: 100%;
margin-left: 32%;
background-color: skyblue;
}
15 changes: 15 additions & 0 deletions prueba.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!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>
<script src ="prueba.js"></script>
</head>
<body>
<form action="prueba.php">
<input type="submit">
</form>
</body>
</html>
14 changes: 14 additions & 0 deletions prueba.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let edad = new FormData();
edad.append('edad', 14);
edad.append('nombre', "Juan");


fetch("./prueba.php", {
method: 'POST',
body: edad
})
.then(res => {
return res.text()
})
.then(data => console.log(data))
.catch(error => console.log(error))
11 changes: 11 additions & 0 deletions prueba.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
if(isset($_REQUEST['edad'])){
$edad = $_REQUEST['edad'];
}
if(isset($_REQUEST['edad'])){
$nombre = $_REQUEST['nombre'];
}
print_r($_REQUEST);

echo "Me llamo $nombre y tengo $edad años";
?>
12 changes: 12 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const account = document.getElementsByClassName("account")[0];
account.addEventListener("click", OpenAccount);
const menuAccount = document.getElementsByClassName("menu-account")[0];
const unlogin = document.getElementsByClassName("unlogin")[0];
unlogin.addEventListener("click", disconect);
function OpenAccount(){
menuAccount.classList.toggle("menu-account_show");
}

function disconect(){
window.location="close_session.php";
}
11 changes: 11 additions & 0 deletions server_session.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();
echo "<pre>";
print_r($_SESSION);
echo "</pre>";

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

echo "<hr>";

//php.ini
$iniRuta = php_ini_loaded_file();
if($iniRuta){
echo "Cargando el fichero php.ini: ".$iniRuta;
} else {
echo "El fichero php.ini no esta cargado";
}
?>
49 changes: 49 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
body {
width: 100vw;
height: 100vh;
background-color: aqua;
place-items: center;
display: flex;
justify-content: center;
}


.container{
width: 20vw;
height: 50vh;
background-color: gray;
place-items: center;
display: flex;
justify-content: center;
border-radius: 23px;
border: 0;

}
label{
font-size: 30px;
}
.formulario{
width: 20vw;
height: 50vh;
place-items: center;
display: flex;
flex-direction: column;
justify-content: center;

}

#submit{
width: 50%;
margin:0 auto;
margin-top: 50px;
background-color: red;
}

input{
width: 50%;
}
.errores{
background-color: rosybrown;
border-radius: 5px;
}

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

$username = $_POST['username'];
$password = $_POST['password'];



$user = "wilson";
$pass = "españita";

if(isset($_SESSION['username'])){
header("Location: panel.php");
}else {
if($username == "" || $password == ""){
$_SESSION["errorVacio"] = "<b>Error:</b> Tienes que rellenar el formulario";
header("Location: index.php");
}
if(($username != $user && $username!="") || ($password != $pass && $password!="")){
$_SESSION["errorSession"] = "<b>Error:</b> El Username o el Password son incorrecto, por favor vuelve a intentarlo";
header("Location: index.php");
}

if ($username == $user && $password == $pass) {
$_SESSION['username']=$user;
$_SESSION['password']=$pass;
header("Location: panel.php");

}
}