I have a site that is being done with PHP + SQL SERVER, and to log in I need the client code, and it puts there only that always says it is incorrect, being correct.
It seems that sqlsrv_num_rows
is not working, because I put the correct login and it does not enter the site that I did.
Login validation code:
<?php
session_start();
$serverName = "10.0.0.0.0";
$connectionInfo = array( "Database"=>"banco", "UID"=>"usuario", "PWD"=>"senha" );
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false ) {
die( print_r( sqlsrv_errors(), true));
}
$var1 = $_POST['codMont'];
$sql = "SELECT *
FROM AB7030 AB7,ABB030 ABB,AB6030 AB6, AA1030 AA, SA1030 SA
WHERE ABB.D_E_L_E_T_ = ''
AND AB7.D_E_L_E_T_ =''
AND AB6.D_E_L_E_T_ = ''
AND SA.D_E_L_E_T_ = ''
AND ABB.ABB_FILIAL = AB6.AB6_FILIAL
AND ABB.ABB_NUMOS = AB6.AB6_NUMOS
AND ABB.ABB_FILIAL = AB7.AB7_FILIAL
AND ABB.ABB_NUMOS = AB7.AB7_NUMOS
AND AB6.AB6_CODCLI = SA.A1_COD
AND AA.AA1_CODTEC = ABB_CODTEC
AND ABB.ABB_CODTEC = '".$var1."'
AND AB7.AB7_TIPO IN ('1','3')
AND AB7_FILIAL = '99'";
$stmt = sqlsrv_query($conn, $sql);
$row_count = sqlsrv_num_rows($stmt);
if ($row_count > 0 ){
$_SESSION['codMont'] = $var1;
header('location:homee.php');
}else{
unset ($_SESSION['codMont']);
$mensagem = "<div class='alert alert-danger'>Código do Montador ou senha incorretos. Tente novamente!</div>";
printf ($mensagem);
printf ($var1);
}
Even if I put the correct or incorrect code does not work, it always says that it does not have a register with this code, but it does. Does anyone know what the problem is?