-2
Good afternoon. I am making a simple login system and I am trying to make a div appear with the message "incorrect user and/or password(s)" if the login is refused. The login system is being done with PHP, and to take out Hidden JS usage. But I have no idea how to have a JS validation to achieve this. (Remembering that PHP is in a separate file and JS inside HTML).
HTML - the div I wish to take out the Hidden
<div class="div"><p>Usuário e/ou senha incorretos.</p>
PHP - login
$user = $_POST['user'];
$pw = $_POST['pw'];
$foi = true;
if(($user == "abc") && ($pw == "abc")){
session_start();
$_SESSION['login-session'] = $user;
$_SESSION['senha-session'] = $pw;
header('Location: restrito/index-restrita.php');
}else{
header("Location: index.php");
$foi = false;
}
JS - script
<script language="javascript" type="text/javascript">
function mostrarErro(){
var log = <?=$foi?>
if(log == false){
document.getElementByClassName('div').style.display = 'block';
}
}
</script>