A great deal of your PHP code was redundant, you can collapse it all into a
single query and the script becomes quite simple:
<?php
if ($_POST['usuario'] != '' && $_POST['password']!= '') {
try {
$db = new PDO("mysql:dbname=encuestasavandaro", "root","chrystopher");
}
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 password = SHA(:password) AND usuario =
:usario');
$query->execute(array('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"]."|".$rol;
}
else {
die ('Error message!');
}
}
?>
Give that a try and see if it works for you (may need to be debugged, as I
didn't test the code).
On Friday, December 28, 2012 3:31:35 PM UTC-5, Chrystopher Medina wrote:
>
> yes my friend please help me to convert my script to PDO¨s
> please.....please thanks again my friend
--
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/-/u0NZORXNyGYJ.
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.