0
I am trying to create in my code a comparison to check if the password entered is equal to registered.
I used it as follows;
function confirmaPedido ($conexao, $numeroPedido, $senha) {
$querySenha = mysqli_query($conexao, "Select senha from adm where senha = $senha");
if (!is_numeric($numeroPedido) || empty($numeroPedido)) {
echo "Por favor insira um NUMERO no campo numero do pedido";
}
elseif ($senha === $querySenha) {
$queryApaga = mysqli_query($conexao, "delete from pedido where pedido = $numeroPedido");
echo "Pedido finalizado com sucesso.";
}
else {
echo "Senha ou Pedido não são validos, tente novamente!";
}
}
If I use the operator to check if $senhaPedido
is exactly the same as $senha
The code jumps to Else.
i received the reply from another user but could not understand very well.
mysqli_query returns a mysqli_result. You will need to usemysqli_fetch_* to pick up the line and then get the "password field".
How so query returns result? what is the difference between the 2? and how do I "select" the password field in the table and check if it is identical?
Thanks for the help Bacco, could you tell me how it would work in Procedural style? I’m still a beginner when it comes to database with PHP, I’m right at the beginning still and I’m trying to turn around using "my logic" understand? I want to see if the way I think it works. .
– RFL
procedural is what I used inside elseif,
$objeto->método()
instead ofmysqli_fetch_row()
I used $return, which is a "result" object, and this object I called the methodfetch_row
.– Bacco
Rafaelacioly see about procedural vs functional in this @rray response: http://answall.com/a/33625/70
– Bacco