Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $email=(empty($_POST['email'])) ? NULL : $_POST['email'];
- $pwd =(empty($_POST['password'])) ? NULL : $_POST['password'];
- if ($email && $pwd && $conn){
- $sql='SELECT * FROM Usuarios WHERE email=? AND password=?';
- $stmt = $conn->prepare($sql);
- if($stmt){
- $stmt->bind_param("ss",$email,$pwd);
- $stmt->execute();
- $stmt->store_result();
- $filas=$stmt->num_rows;
- if($filas>0){
- $arrDatos=myGetResult($stmt);
- $_SESSION['usuario']=$arrDatos;
- header('Location: consola.php');
- $stmt->close();
- $conn->close();
- }
- else
- {
- echo "No se encontraron registros";
- }
- }
- else
- {
- echo "Error en la consulta: ".$stmt->error;
- }
- }
- else
- {
- echo "Falta alguno de los datos del POST o la conexión es nula";
- }
- function myGetResult( $Statement ) {
- $RESULT = array();
- $Statement->store_result();
- for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
- $Metadata = $Statement->result_metadata();
- $PARAMS = array();
- while ( $Field = $Metadata->fetch_field() ) {
- $PARAMS[] = &$RESULT[ $i ][ $Field->name ];
- }
- call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
- $Statement->fetch();
- }
- return $RESULT;
- }
Add Comment
Please, Sign In to add comment