Logros-de-la-vida/server/identificarUsuario.php

28 lines
671 B
PHP
Raw Permalink Normal View History

2014-07-20 15:36:23 +02:00
<?php
if(isset($_GET['alias']) && isset($_GET['pass']) && isset($_GET['callback'])) {
//Bibliotecas
require 'DB.class.php';
//Variables
$sAlias = $_GET['alias'];
$sPass = $_GET['pass'];
$sSQL = 'SELECT id, count(id) AS numero FROM usuarios WHERE alias
= \'' . $sAlias . '\' AND password = \'' . $sPass . '\'';
$miDB = new DB();
$aFinal;
//Obtener resultados
$aRes = $miDB->obtenerResultado($sSQL);
if($aRes[0]['numero'] > 0) {
$aFinal = array('usuario' => $aRes[0]['id']);
} else {
$aFinal = array('usuario' => '0');
}
//Devuelve JSON
header('Content-Type: application/json');
echo $_GET['callback'] .'(' . json_encode($aFinal) . ')';
}
?>