-
Notifications
You must be signed in to change notification settings - Fork 0
/
principal.php
165 lines (123 loc) · 6.99 KB
/
principal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php session_start(); ?>
<?php require("cabecera.inc"); ?>
<?php
global $wppa;//variables globales, 2 arrays, wppa con las variables que el usuario pone, creedeciales los nombres que le quieras poner a las cookies
global $Creedenciales;
$Creedenciales = array( "Usuario" , "Contraseña");
print_r ($wppa)."\n" ;//imprime el array
if(isset($_POST['enviar'])){//isset se hace una vez el usuario le de a enviar
if(empty($_POST['usuario']) || empty($_POST['password']))//empty comprueba que no haya un campo vacio, como el bernabeu ahora mismo
echo '<br>Debes llenar todos los datos';
elseif($_POST['usuario']=="teste" and $_POST['password']=="teste"){//ejemplo que he puesto, si esta bien pa dentro
$wppa = array($_POST["usuario"] ,$_POST["password"]);
$_SESSION['usuario']=$_POST['usuario'];
$_SESSION['password']=$_POST['password'];
echo '<br>Te logiaste perra, tu usuario es '.$_SESSION['usuario'];
header("Location: principallogged.php");
}
elseif($_POST['usuario']!="teste" or $_POST['password']!="teste"){//no cumple el ejemplo, pa tu casa
echo '<br>Creedenciales incorrectos tolai';
}
}
if(isset($_POST['enviar'])){
if(isset($_POST['cbox1']) and $_POST['cbox1'] == '1') {
if($wppa[0]=="teste" && $wppa[1]=="teste"){// comprueba que el usuario se pueda meter, se puede meter arriba, pero esta aqui pa que se vea bienif(isset($_POST['enviar']))
//crea las cookies, 3 parametros ( nombre de la cookie, valor de la cookie, tiempo de expiracion de la cookie)
setcookie( $Creedenciales[0], $wppa[0] , time() + (86400 * 90+3600), "/"); // 86400 = 1 day
setcookie( $Creedenciales[1], $wppa[1] , time() + (86400 * 90+3600), "/"); // 86400 = 1 day
printf("<br> tus cookies se han guardado desgraciao");
}
}
else{
printf("<br> tus cookies NO se han guardado desgraciao");
}
}
//MANTENER SESION ABIERTA
if (isset($_COOKIE[$Creedenciales[0]])) {
session_register("susuario"); // registrar $variable en session.
$susuario=[$wppa[0]];; // El valor de la $variable se puede dar
$_SESSION['usuario']=$_COOKIE[$Creedenciales[0]];
$_SESSION['password']=$_COOKIE[$Creedenciales[1]];
header("Location: principallogged.php");
}
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- El cuerpo -->
<body>
<header>
<a title="FlicktriX - Página de inicio" href="principal.php"><img id="logo" src="camera.png" alt="logo" /></a>
</header>
<nav id="menuIconos">
<input type="checkbox" id="ckbmenu">
<ul>
<li><label for="ckbmenu">≡</label></li>
<li id="inicio"><a href="principal.php"><span class="glyphicon glyphicon-home"></span> <span>Inicio</span></a></li>
<li id="busqueda"><a href="busqueda.php"><span class="glyphicon glyphicon-screenshot"></span> <span>Buscar</span></a></li>
<li id="registro"><a href="registro.php"><span class="glyphicon glyphicon-plus"></span> <span>Registro</span></a></li>
<!-- El cuerpo
<li><a href="principal.html"><span> </span><span>FlicktriX</span></a></li>
<li><a href="principal.html"><span></span> <span>FlicktriX</span></a></li>
<li><a href="registrado.html"><span></span> <span>Usuario registrado</span></a></li>
<li><a href="busqueda.html"><span ></span> <span>Buscar</span></a></li>
<li><a href="registro.html"><span></span> <span>Registro</span></a></li>
-->
</ul>
</nav>
<br>
<form id="loginPrincipal" action="principal.php" method="POST" >
<label>Nombre: <input type="text" name="usuario" id="usuario" required ></label>
<label>Contraseña: <input type="password" name="password" id="password" required pattern="[a-zA-Z0-9_-]*" title="Por favor, los caracteres introducidos no son validos" maxlength="20" minlength="5"></label></input>
<button type="submit" class="boton" name="enviar" id="submit">Login</button><br>
<label>REcuerdame como si fuera esta la primera veeez: <input type="checkbox" name="cbox1" value="1"></label><br>
</form>
<br>
<section>
<h2 class="tituloSec">COMPARTE TUS FOTOS CON TUS AMIGOS.</h2>
<div>
<article>
<a title="foto" href="ultimafoto.html"> <div align="center"><img id="ultsfotos" src="foto.jpg"></div></a>
<p style="text-align:center">Descripción</p>
<br>
<footer>
<div style="text-align:center"><a href=""><pie>Autor</a></pie></div>
</footer>
</article>
<article>
<a title="foto" href="ultimafoto.html"> <div align="center"><img src="foto.jpg"></div></a>
<p style="text-align:center">Descripción</p>
<br>
<footer>
<div style="text-align:center"><a href=""><pie>Autor</a></pie></div>
</footer>
</article>
<article>
<a title="foto" href="ultimafoto.html"> <div align="center"><img src="foto.jpg"></div></a>
<p style="text-align:center">Descripción</p>
<br>
<footer>
<div style="text-align:center"><a href=""><pie>Autor</a></pie></div>
</footer>
</article>
<article>
<a title="foto" href="ultimafoto.html"> <div align="center"><img src="foto.jpg"></div></a>
<p style="text-align:center">Descripción</p>
<br>
<footer>
<div style="text-align:center"><a href=""><pie>Autor</a></pie></div>
</footer>
</article>
<article>
<a title="foto" href="ultimafoto.html"> <div align="center"><img src="foto.jpg"></div></a>
<p style="text-align:center">Descripción</p>
<br>
<footer>
<div style="text-align:center"><a href=""><pie>Autor</a></pie></div>
</footer>
</article>
</div>
</section>
<?php require("pie.inc"); ?>
<p>
</p>
</body>
</html>