Good afternoon, I'm having a big problem where I can not change the password on the system. What is driving me is that it seems that sqlsrv_fetch_array works differently from mysql_fetch_array, I have a code like that using MySQL and it works fine but in SQL Server it is not, so I came here asking for help on that system. >
public function alterarsenha($Nome, $Senha, $Novasenha, $Confirnovasenha){
$sql = "SELECT SENHA FROM CADPES WHERE NOME = '$Nome'";
$query = sqlsrv_query($this->Conn->Conectar(), $sql) or die( print_r( sqlsrv_errors(), true));
$senhabanco = '';
while($row = sqlsrv_fetch_array($query, SQLSRV_FETCH_ASSOC)){
$senhabanco = $row['SENHA'];
}
if(($Senhanova == "") OR ($Confirsenha) == "" ){
echo "Insira a nova senha!";
//header('location:index.php');
}else{
if($Senha != $senhabanco){
echo "Nome ou senha inválido!";
}else{
if($Novasenha != $Confirnovasenha){
echo "Campos da nova senha não conferem!";
}else{
$upd = "UPDATE CADPES SET SENHA = '$Novasenha' WHERE NOME = '$NOME'";
$upd_query = sqlsrv_query($this->Conn->Conectar(), $sql);
if($upd_query){
echo "Senha alterado com sucesso";
//header('location:index.php');
}else{
echo "Ocorreu um erro na trocra de Números";
//header('location:index.php');
}
}
}
}
I'm stuck here!
if($Senha != $senhabanco){
echo "Nome ou senha inválido!";
}else{
Do not leave this condition the problem is that the variable $ senhabanco always has the value NULL even though I have done the while. And even tried to change the place key put at the end but it results in another error.