-
Notifications
You must be signed in to change notification settings - Fork 1
/
validacion.php
58 lines (49 loc) · 1.2 KB
/
validacion.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 'datos/conf.php';
if($_SESSION['user'] != ""){
}
else{
header('Location:login.php');
}
$usuario = (isset($_POST['txtUser']) ? $_POST['txtUser']:"");
$pass = (isset($_POST['txtPass']) ? $_POST['txtPass']:"");
if ($usuario != "" && $pass != ""){
session_start();
$Obj_datos = new Datos();
$array = $Obj_datos->Conectar()->medicos->find(['usuario'=>$usuario]);
foreach($array as $datos){
$userfind = $datos['usuario'];
$passfind = $datos['pass'];
$id = $datos['_id'];
$nombres = $datos['nombres'];
$apellidos = $datos['apellidos'];
$tipousuario = $datos['tipousuario'];
}
if (isset($userfind)==NULL){
$msj = "El usuario no existe";
$val = false;
}
else if ($userfind == $usuario && $passfind != $pass){
$msj = "Contraseña incorrecta";
$val = false;
}
else if($userfind == $usuario && $passfind == $pass){
$_SESSION['user'] = $userfind;
$_SESSION['id'] = $id;
$_SESSION['nombres'] = $nombres;
$_SESSION['apellidos'] = $apellidos;
$_SESSION['tipousuario'] = $tipousuario;
$val = true;
}
else {
$val = false;
$msj = "Parametros incorrectos";
}
if ($val){
header('Location:index.php');
}
else {
header('Location:login.php?me='.$msj);
}
}
?>