-1
Hello! I created a modal to call the login inputs. But when I click "Login" on the Ubmit button, if it is empty or with incorrect information, it closes the modal and does not show me error message as expected... I’m starting to learn php and javascript, so I don’t know what I’m doing wrong, if you can help me I appreciate!
Code I’m using in my index.php to call the modal:
<!-- Trigger button do modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#loginmodal">Login</button>
<!-- Modal -->
<div class="modal fade" id="loginmodal" tabindex="-1" role="dialog" aria-labelledby="loginlabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="loginlabel">Login</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<?php include 'loginform.php';?> <!-- Aqui vc chama a sua página -->
</div>
</div>
</div>
</div>
My login page "loginform.php":
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<?php
if(isset($_SESSION['nao_autenticado'])):
?>
<div class="notification is-danger">
<p>ERRO: Usuário ou senha inválidos.</p>
</div>
<?php
endif;
unset($_SESSION['nao_autenticado']);
?>
<div class="box">
<form action="login.php" method="POST">
<div class="field">
<div class="control">
<input name="usuario" name="text" class="input is-large" placeholder="Seu usuário" autofocus="">
</div>
</div>
<div class="field">
<div class="control">
<input name="senha" class="input is-large" type="password" placeholder="Sua senha">
</div>
</div>
<button type="submit" name="login" class="button btn btn-secondary" >Login</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fechar</button>
</form>
</div>
</body>
I forgot to mention that the modal only closes when it has some incorrect login information. When it works it redirects me to the desired page. After giving Submit and opening the modal again, the error is there appearing...
– Dokitos
Forgot to inform where you are creating $_SESSION['nao_authenticated']
– user60252
What’s the difference between login.php and loginform.php? What does login.php do?
– user60252