Good evening, everyone!
I'm having a problem with my application. The problem is as follows, I have a form to login and a button of type submit
, when I click on this button, the form is submitted to validate and verify the login, but then, after validating I would like div
update with the user name.
Here is my visual page code, where is my form and my function that would respectively update the div
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script><scripttype="text/javascript">
$(document).ready(function(){
$("#menu #formLogin").submit(function(e){
e.preventDefault();
var href = "../View/dropdown.php";
$("#dropdown").load(href + "#dropdown");
});
});
</script>
<div class="dropdown" id="dropdown">
<center> <li style="display: block; width: 100px; margin-right: 10px; margin-left: 40px;"><a style="color: #ccc; text-decoration: none;" href="#"> <img src="../images/user.png" width="35px"><br> Minha conta </a></li> </center>
<div class="dropdown-content">
<form name="formLogin" id="formLogin" action="../Controller/verificaLogin.php" method="post">
<input style="width:250px;" type="email" id="userLogin" name="userLogin" placeholder="Digite seu email">
<br>
<input style="width:250px;" type="password" id="userPassword" name="userPassword" placeholder="Digite sua senha">
<br>
<input type="submit" value="Entrar" id="btnLogar" name="btnLogar" style="width: 100px;" >
<a name="recuperaSenha" id="recuperaSenha" href="#"> Esqueci minha senha </a>
<br> <br>
<p style="color: #777"> Ainda não pussui conta? <a style="text-decoration: underline;" name="Cadastro" id="Cadastro" href="cadCliente.php"> Cadastre-se </a> </p>
</form>
</div>
</div>
Here is the code that checks the login
include '../Model/conectaBanco.php';
include '../Model/clienteVO.php';
include '../Model/loginDAO.php';
include 'verificaSessao.php';
$cliente = new clienteVO();
$loginDAO = new loginDAO;
$mysqli = new mysqli("localhost", "root", "", "bdAliSantos");
if(NULL !== filter_input(INPUT_POST, "btnLogar")){
$cliente ->setEmailLogin(filter_input(INPUT_POST, "userLogin"));
$cliente ->setSenhaLogin(filter_input(INPUT_POST, "userPassword"));
$senhaVerificar = $cliente->getSenhaLogin();
if(!$cliente ->getEmailLogin() || !$cliente->getSenhaLogin()){
echo "<script> alert('Por favor, verifique se digitou seu email e/ou senha corretamente'); document.location.href = '../View/index.php'; </script>";
} else {
$nomeCliente = $loginDAO ->selecionaNome($cliente);
$senhaCliente = $loginDAO ->selecionaSenha($cliente);
if(($nomeCliente && $senhaCliente) && ($senhaCliente === $senhaVerificar)){
if($cliente->getEmailLogin()=== "[email protected]"){
$_SESSION['nomeUsuario'] = "Admin";
$_SESSION['senhaUsuario'] = $senhaCliente;
header("Location: ../View/indexAdm.php");
}else{
$_SESSION['nomeUsuario'] = $nomeCliente;
$_SESSION['senhaUsuario'] = $senhaCliente;
header("Location: ../View/index.php");
}
}
else{
header("Location: ../View/index.php");
}
}
}
And this is the code I would like div
to load after submission
<div class="dropdown" id="dropdown">
<center> <li style="display: block; width: 100px; margin-right: 10px; margin-left: 40px;"><a style="color: #ccc; text-decoration: none;" href="#"> <img src="../images/user.png" width="35px"><br> <?php echo $_SESSION['nomeUsuario']; ?></a></li> </center>
<div class="dropdown-content" style="padding: 0">
<ul style="list-style-type: none; margin: 0; width: 200px; padding: 0;">
<li><a href="../View/minhaConta.php" style="color: #777;"> Minha Conta </a></li>
<li><a href="#" style="color: #777;"> Meus Pedidos </a></li>
<li><a href="../View/minhasConfiguracoes.php" style="color: #777;"> Configurações </a></li>
<li><a href="../Controller/sair.php" style="color: #777;"> Sair </a></li>
</ul>
</div>
That's it .. Right now, thank you.