-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathingresar.php
83 lines (61 loc) · 2.05 KB
/
ingresar.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
<?php
$usuario=$_POST['user'];
$clave=$_POST['clave'];
try{
require_once('includes/funciones/db_connection.php');
$sql="SELECT * FROM usuarios WHERE email='".$usuario."' AND id_tipo=1";
$sql2="SELECT * FROM usuarios WHERE email='".$usuario."' AND id_tipo=2";
$resultados=$conn->query($sql);
$resultados2=$conn->query($sql2);
}catch(\Exception $e){
echo $e->getMessage();
}
$usuarios_base=array();
$usuarios_base2=array();
while ($usuarios=$resultados->fetch_assoc()) {
$usuarios_base[]=$usuarios;
}
while ($usuarios2=$resultados2->fetch_assoc()) {
$usuarios_base2[]=$usuarios2;
}
?>
<?php
if (count($usuarios_base)==0) {
echo'<script type="text/javascript">
alert("CREDENCIALES INCORRECTAS");
window.location.href="index.php";
</script>';
}
foreach ($usuarios_base as $admin){
if ($usuario==$admin['email'] && $clave==$admin['clave'] ) {
session_start();
$_SESSION["administracion"]= $usuario;
header("Location: admin/admin.php");
}else{
echo'<script type="text/javascript">
alert("CREDENCIALES INCORRECTAS");
window.location.href="index.php";
</script>';
}
}
?>
<?php
if (count($usuarios_base2)==0) {
echo'<script type="text/javascript">
alert("CREDENCIALES INCORRECTAS");
window.location.href="index.php";
</script>';
}
foreach ($usuarios_base2 as $operador){
if ($usuario==$operador['email'] && $clave==$operador['clave'] ) {
session_start();
$_SESSION["operador"]= $usuario;
header("Location: operador.php");
}else{
echo'<script type="text/javascript">
alert("CREDENCIALES INCORRECTAS");
window.location.href="index.php";
</script>';
}
}
?>