-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrud.php
More file actions
61 lines (49 loc) · 1.52 KB
/
crud.php
File metadata and controls
61 lines (49 loc) · 1.52 KB
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
<?php
include "conexion.php";
$usuario = $conexion->real_escape_string($_POST['usuario']);
$passwd = $conexion->real_escape_string($_POST['passwd']);
$sql = <<< SQL
SELECT idCargo
from empleado
where usuario = '$usuario' and pass = sha2('$passwd',512)
SQL;
$sentencia = $conexion->prepare($sql);
if (!$sentencia){
die("Error al preparar: ");
}
$sentencia->execute();
if ($sentencia->errno){
die("Error al ejecutar: ".$sentencia->error);
}
$sentencia->bind_result($cargo);
$validar=0;
while ($sentencia->fetch()){
$validar=1;
}
$sentencia->close();
$conexion->close();
if ($validar==0) {
echo "Login incorrecto";
echo '<meta http-equiv="refresh" content="1;URL=login.html">';
echo '<a href="representante.php">Pincha aquí si tienes prisa</a>';
}
switch ($cargo) {
case "1":
echo '<meta http-equiv="refresh" content="3;URL=representante.php">';
echo '<a href="representante.php">Pincha aquí si tienes prisa</a>';
break;
case "2":
echo '<meta http-equiv="refresh" content="3;URL=vicepresidente.php">';
echo '<a href="comercial.php">Pincha aquí si tienes prisa</a>';
break;
case "3":
echo '<meta http-equiv="refresh" content="3;URL=gerente.php">';
echo '<a href="gerente.php">Pincha aquí si tienes prisa</a>';
break;
case "4":
echo '<meta http-equiv="refresh" content="3;URL=coordinador.php">';
echo '<a href="coordinador.php">Pincha aquí si tienes prisa</a>';
break;
default:
break;
}