I have a Login page, which has a form, which sends the data of two fields (username and password) to a PHP file that performs the verification. This php file uses a function already written to a class. In this function, if the result is true, a redirect happens, otherwise it will execute a Jquery code to display an "Invalid Password" message on the login page. The intention is for this Jquery to change ownership of a certain element from "hidden" to "visible", thus displaying the message on the screen.
I'm a little confused, and I've never gotten right with jQuery, nor do I know if I'm forgetting some important detail, so I'd like a good soul to give me a help. HTML:
<?php
header("Content-Type: text/html; charset=ISO-8859-1", true);
?>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<title>Login</title>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="css/login_style.css">
</head>
<body>
<div class="login-page">
<div class="form">
<form class="login-form" action="verificacaologin.php" method="post">
<input type="text" placeholder="Usuário" name="nome_usuario"/>
<input type="password" placeholder="Senha" name="senha"/>
<button type="submit">login</button>
</form>
<label class="senha_incorreta">Senha incorreta.Tente novamente.</label>
</div>
</div>
</body>
</html>
Php that checks:
<?php
include_once 'classes/Usuario.php';
$nome = $_POST['nome_usuario'];
$senh = $_POST['senha'];
$usuario = new Usuario();
$usuario->verificarExistenciaLogin( $nome , $senh);
?>
Function of the User class that contains Jquery:
public function verificarSenhaCorreta( $nome_usuario , $senha )
{
$query = "select SENHA from portfolio.usuario where NOME_USUARIO = '$nome_usuario' ";
$conexao = new Conexao();
$resultado_consulta = $conexao->abrirConexao( $query );
$resultado_consulta = implode($resultado_consulta);
if( $resultado_consulta == $senha )
{
header("Location:ordem_servico.php");
}
else
{
//mostrar mensagem de que a senha está incorreta();
?>
//Aqui que minhas dúvidas começam
<script>
$(document).ready(function()
{
$('.senha_incorreta').css( "visibility" , "visible" );
});
</script>
<?php
}
}