-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
58 lines (48 loc) · 1.23 KB
/
login.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
<?php
require_once("sesion.class.php");
$sesion = new sesion();
if( isset($_POST["iniciar"]) )
{
$usuario = $_POST["usuario"];
$password = $_POST["contrasenia"];
if(validarUsuario($usuario,$password) == true)
{
$sesion->set("usuario",$usuario);
header("location: principal.php");
}
else
{
echo "Verifica tu nombre de usuario y contrase�a";
}
}
function validarUsuario($usuario, $password)
{
$conexion = new mysqli("localhost","usuario","password","base");
$consulta = "select contrasenia from usuario where nick = '$usuario';";
$result = $conexion->query($consulta);
if($result->num_rows > 0)
{
$fila = $result->fetch_assoc();
if( strcmp($password,$fila["contrasenia"]) == 0 )
return true;
else
return false;
}
else
return false;
}
?>
<html>
<head>
<title></title>
</head>
<body>
<form name="frmLogin" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<div>
<div> <label>Usuario: </label> <input type="text" name = "usuario"/></div>
<div><label>Contraseña: </label> <input type="password" name = "contrasenia" /></div>
<div><input type="submit" name ="iniciar" value="Iniciar Sesion"/></div>
</div>
</form>
</body>
</html>