2
I am trying to close an alert automatically after the user performs registration/login.
The alert is working in a good, as soon as the query in the Database is held the alert appears on the screen.
But I would like the alert to disappear even if the user does not close it.
My code is like this:
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<div class="container">
<!-- CADASTRO SUCESSO -->
<?php
if($_SESSION['status_cadastro']):
?>
<div class="modalBanner d-flex justify-content-center" role="alert">
<div class="alert alert-success">
<strong>Cadastro efetuado!</strong> Faça login informando seu e-mail e senha. 
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
</div>
<?php
endif;
unset($_SESSION[status_cadastro]);
?>
<!-- E-MAIL EM USO -->
<?php
if($_SESSION['usuario_existe']):
?>
<div class="modalBanner d-flex justify-content-center" role="alert">
<div class="alert alert-danger">
Este e-mail já está em uso. Utilize-o para login ou informe outro. 
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
</div>
<?php
endif;
unset($_SESSION[usuario_existe]);
?>
</div>
I tried using the following Javascript:
$(document).ready(function() {
// show the alert
setTimeout(function() {
$(".modalBanner").alert('close');
}, 2000);
});
But I have not yet succeeded. The alert is only shown after the php
check the emails in the database.
Man, sorry for the delay. I marked your answer as accepted. Someone gave me markdown, if you can give me a moral and give a helpful thank you. Thanks!!
– Arnon
Okay, I’ll dial here
– andre_luiss