The value of the output is always null. PHP and MySql

0

I have a problem. The procedure returns an output value (boolean type) and when I pick it up in the php code it is always null. Any solution?

Thank you!

MYSQL STORED PROCEDURE:

BEGIN    
   IF EXISTS (SELECT * FROM cliente WHERE usuario LIKE p_usuario AND 
         contrasena LIKE p_contrasena) THEN
        SET p_salida = 1;
ELSE
        SET p_salida = 0;
  END IF;    
END

PHP CODE:

<?php
if(isset($_POST['txtUsuario']))
{
// Almacenar los datos de la base de datos en variables
$usuario = "root";
//$contrasena
$servidor = "localhost";
$basededatos = "proyecto";

// Crear la conexion con el servior de la base de datos

$conexion = mysqli_connect($servidor, $usuario); 

//Comprobar conexion 

if ($conexion->connect_error) {
die("Conexion fallida:" . $conexion->connect_error);}

// Crear conexion con la base de datos
$db = mysqli_select_db($conexion, $basededatos);

// Declarar como variables los input 
$usuario=$_POST['txtUsuario'];
$contrasena=$_POST['txtContrasena'];


$sqlpro = "CALL pr_login($usuario,$contrasena,'@p_salida')";
$rdo=mysqli_query($conexion,"SELECT @p_salida as salida");
echo $rdo;
      $fila=mysqli_fetch_assoc($rdo);
      if($fila['salida']==1)
           echo 'BUENO';
      else
        echo 'MALO';

 }
 else
 ?>
 <html>
 <body>

<form action="" method="post">
    Usuario: 
    <input name="txtUsuario" type="text" /><br/>
    Contraseña:
    <input name="txtContrasena" type="password" /><br/>
    <input name="txtIniciarSesion" type="submit" value="Iniciar sesion" 
/>
</form>
</body>
</html>'
    
asked by Aitor Palleja 27.11.2018 в 18:55
source

1 answer

2

You are not running the stored procedure. You must use the statement mysqli_query ($ connection, $ sqlpro); before collecting the output value.

A fellow greeting

    
answered by 27.11.2018 / 19:00
source