1
I’m trying to get the code to check if the passwords are identical and if they were, saved in the comic book, but I don’t know what’s wrong that regardless of whether it’s identical or not it always saves.
if (isset($_POST['salvar-senha'])) {
$usr_id = $_SESSION['usr_id'];
$senha_atual = md5(strip_tags($_POST['senha_atual']));
$senha_nova = md5(strip_tags($_POST['senha_nova']));
$confirme_senha = md5(strip_tags($_POST['confirme_senha']));
$sql = mysql_query("SELECT usr_password FROM users WHERE usr_login = '$usr_id' ");
$row = mysql_fetch_array($sql);
$senha_banco = $row['usr_password'];
if($senha_atual == "" && $senha_nova == "" && $confirme_senha == "") {
echo "
<script>
alert('Os campos das senhas não podem ser nulos.');
window.location='../configuracoes.php';
</script>";
} else {
if (($senha_atual != $senha_banco) && ($senha_nova != $confirme_senha) ) {
echo "
<script>
alert('As senhas não conhecidem.');
window.location='../configuracoes.php';
</script>";
} else {
if ($result=mysql_query("UPDATE users SET usr_password = '$confirme_senha' WHERE usr_id = '$usr_id' ")) {
echo "
<script>
window.location='../configuracoes.php?success=yes';
</script>";
}
}
}
}
Boy, I did that and now I can only say that the passwords don’t match. Until I put the 3 equal.
– Altemberg Andrade
Are you sure the current password md5 matches what is in the bank? You tried to print the values to confirm?
– bfavaretto
Yes, both the current password matches the bank’s, as well as the new password and confirmation.
– Altemberg Andrade