What doesn't work?
On Friday, December 28, 2012 8:20:02 PM UTC-5, Chrystopher Medina wrote:
>
> my friend i tried the query and its ok...... but it doesn´t work....
> if echo 0 = the user has been logued in... if echo 1= the values are wrong
> and if echo 2; = there are not values entered by the user
>
> <?php
> if ($_POST['usuario']!= '' && $_POST['password']!= ''){
> $username = "root";
> $password = "chrystopher";
> $databasename = "encuestasavandaro";
> try {
> $db = new PDO("mysql:dbname=$databasename",$username,$password);
> }
> catch (PDOException $e) {
> die ($e->getMessage());
> }
>
> $query = $db-> prepare('SELECT a.rol, b.usuario FROM rollusuario a,
> usuarios b WHERE a.id_rol = b.id_rol AND b.password = SHA(:password) AND
> b.usuario = :usuario');
> $query->execute(array( 'password' => $_POST['password'], 'usario'
> => $_POST['usuario']));
> $results = $query->fetchAll(PDO::FETCH_ASSOC);
> // gracefully exit the database
> $query = null;
> $db = null;
> if (count($results) == 1) {
> // this is actually sufficient to say the user is logged in, no need for
> anything else
> session_start();
> $_SESSION["autentificado"]= true;
> $_SESSION["usuario"]= $_POST["usuario"]."|".$results[0]['rol'];
> echo 0;
> }
> else {
> echo 1;
> }
> }else{
> echo 2;
> }
> ?>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/ND0m7lHIie8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.