Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. $email=(empty($_POST['email'])) ? NULL : $_POST['email'];
  2. $pwd =(empty($_POST['password'])) ? NULL : $_POST['password'];
  3.  
  4. if ($email && $pwd && $conn){
  5. $sql='SELECT * FROM Usuarios WHERE email=? AND password=?';
  6. $stmt = $conn->prepare($sql);
  7. if($stmt){
  8. $stmt->bind_param("ss",$email,$pwd);
  9. $stmt->execute();
  10. $stmt->store_result();
  11. $filas=$stmt->num_rows;
  12. if($filas>0){
  13. $arrDatos=myGetResult($stmt);
  14. $_SESSION['usuario']=$arrDatos;
  15. header('Location: consola.php');
  16. $stmt->close();
  17. $conn->close();
  18. }
  19. else
  20. {
  21. echo "No se encontraron registros";
  22. }
  23. }
  24. else
  25. {
  26. echo "Error en la consulta: ".$stmt->error;
  27. }
  28. }
  29. else
  30. {
  31. echo "Falta alguno de los datos del POST o la conexión es nula";
  32. }
  33. function myGetResult( $Statement ) {
  34. $RESULT = array();
  35. $Statement->store_result();
  36. for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
  37. $Metadata = $Statement->result_metadata();
  38. $PARAMS = array();
  39. while ( $Field = $Metadata->fetch_field() ) {
  40. $PARAMS[] = &$RESULT[ $i ][ $Field->name ];
  41. }
  42. call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
  43. $Statement->fetch();
  44. }
  45. return $RESULT;
  46. }
Add Comment
Please, Sign In to add comment