I'm starting to venture into the world of web programming and am having difficulty with the following subject: I am creating a page for password change. I would like my code to compare the login that the user is trying to change the password, with the login that is assigned in my session, converting the login to lowercase and then doing the comparison.
<script>
function validar(){
var login = formlogin.nlogin.value;
var senha = formlogin.nsenha.value;
var novasenha = formlogin.novasenha.value;
var logado = "<?php echo $logado?>"
if (login != logado.toLowerCase()){
alert('Você não pode alterar a senha para este usuário.');
formlogin.nlogin.focus;
return false;
}
if (login == ''){
alert('Preencha o campo de login');
formlogin.nlogin.focus;
return false;
}
if (senha == ''){
alert('Preencha o campo de senha');
formlogin.nsenha.focus;
return false;
}
if (novasenha == ''){
alert('Preencha o campo Nova senha');
formlogin.novasenha.focus;
return false;
}
}
</script>
When I make the comparison, even with the string converted to lowercase, I get the message that it is impossible to change the user.
Any tips?