-
Notifications
You must be signed in to change notification settings - Fork 0
/
dao_aplicacion.php
35 lines (32 loc) · 789 Bytes
/
dao_aplicacion.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
<?php
require_once( 'tablas.php' );
require_once( 'db_util.php' );
function login( $usr, $pass )
{
global $con;
try
{
$query = 'select id, nombre, usuario, contrasena '
.'from usuario where usuario = :usuario and contrasena = :contrasena ';
$ps = $con->prepare( $query );
$ps->bindParam( ':usuario', $usr );
$ps->bindParam( ':contrasena', $pass );
$ps->execute();
$res = $ps->fetch( PDO::FETCH_ASSOC );
if ( is_bool( $res ) or ( is_array( $res ) and count( $res ) == 0 ) )
{
$ans = array( 'resultado' => false,
'mensaje' => 'Usuario no encontrado');
}
else
{
$ans = array('resultado' => true, 'usuario' => $res );
}
}
catch ( PDOException $ex )
{
$ans = array( 'resultado' => false, 'mensaje' => $ex->getMessage() );
}
return $ans;
}
?>