This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
forked from Cruba/foodBit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiniciarsesion.php
127 lines (94 loc) · 3.47 KB
/
iniciarsesion.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
<!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">
<link rel="shortcut icon" href="img/logo.png">
<title>FoodBit</title>
<link rel="preload" href="css/style.css" as="style">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/normalize.css">
<?php
if(isset($_POST['entrar'])) {
require("conexion.php");
$correo = $conexion ->real_escape_string($_POST['correo']);
$password = md5($_POST['password']);
$consulta = "SELECT correo,pass,identificador, nombre FROM usuarios WHERE correo = '$correo' AND pass = '$password'";
if($resultado = $conexion->query($consulta)) {
while($row = $resultado->fetch_array()) {
$userok = $row['correo'];
$passok = $row['pass'];
$id = $row['identificador'];
$name = $row['nombre'];
}
$resultado->close();
}
$conexion->close();
if(isset($correo) && isset($password)) {
if($correo == $userok && $password == $passok) {
session_start();
$_SESSION['identificador'] = TRUE;
$_SESSION['nombre'] = $name;
$_SESSION['correo'] = $userok;
$_SESSION['id'] = $id;
header("Location: userindex.php");
}
else {
Header("Location: iniciarsesion.php?error=login");
}
}
} ?>
</head>
<body class="fondogris">
<header class="header2">
<div class="contenedor">
<div class="barra">
<a class="logo no-margin centrar-texto" href="index.php">
<h1 class="logo__nombre">Food<span class="logo__bold">Bit.</span></h1></a>
<nav class="navegacion">
<a href="registrar.html" class="navegacion__enlace">Registrar</a>
</nav>
</div>
</div>
</header>
<div class="spacer-30"></div>
<div class="spacer-30"></div>
<main class=" ">
<div class="contenedor2">
<form class="formulario fondoblanco" action="" method="post">
<div class="barrita"></div>
<?php
if(isset($_GET['true'])) {
echo " <br><center class='mensaje exitoso'>Registro exitoso inicia sesión</center>";
}
?>
<h2>Iniciar Sesión</h2>
<div class="margin-2">
<label class="campo__label2" for="email">Correo</label>
<input class="campo__field2" type="email" id="email" name="correo" required>
</div>
<div class="margin-2">
<label class="campo__label2" for="password">Contraseña</label>
<input name="password" type="password" class="campo__field2" id="password" required>
</div>
<div class="">
<input type="submit" value="Iniciar Sesión" class="boton2 boton--primario" name="entrar">
<?php
if(isset($_GET['error'])) {
echo "<center class='mensaje fallido'>Error el usuario o contraseña no coinciden</center>";
}
?>
</div>
</form>
</div>
</main>
<div class="spacer-30"></div>
<div class="spacer-30"></div>
<div class="spacer-30"></div>
<footer class="footer">
<div class="contenedor">
</div>
</footer>
</body>
</html>