Reputation: 13
i have a very simple email form that i want to make a modal popup show when the "Send Message" button is activated saying wetter or not the email was sent. I'm using bootstrap, and i already made a modal popup on another page, but I can't find a way to make It from the PHP.
<form name="contactform" method="post">
<br><input type="text" name="txtNome" placeholder="Insira o seu nome." required id="campoNome"><br>
<input type="email" name="txtEmail" placeholder="Insira o seu e-mail." required id="campoEmail"><br>
<input type="text" name="txtTelefone" id="campoTelefone" placeholder="Insira o seu telefone." required><br>
<textarea name="txtMensagem" maxlength="1000" cols="25" rows="6" placeholder="Deixe aqui sua mensagem." required id="campoMensagem"></textarea><br>
<input type="submit" name="btnEnviar" value="SEND MESSAGE" id="btnEnviar">
</form>
<?php
//enviar formulário
if(isset($_POST['btnEnviar']))
{
if ($enviado)
{
echo "<span class='text-success'>E-mail sent!</span>";
}
else
{
echo "<span class='text-danger'>Something wrong happened :(.</span><br>";
}
}?>
I did as Andrew told me to, but still can't manage to make it work, I'm really new at developing so please be nice to me :)
<div class="modal fade" id="emailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="text-indent: justify;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4>A área de clientes ainda está em construção, agradecemos a compreensão</h4>
<br>
<br>
<button type="button" class="btn btn-default" data-dismiss="modal" style="background-color: #2980B9; color: white;">OK</button>
</div>
</div>
</div>
</div>
<?php
//enviar formulário
if(isset($_POST['btnEnviar']))
{
if ($enviado)
{
echo "<span class='text-success'>E-mail sent!</span>";
}
else
{
echo "<script type='text/javascript'>
$(document).ready(function(){
$('#emailModal').modal('show');
});
</script>";
}
}?>
Upvotes: 1
Views: 6571
Reputation: 31
@error('email')
<script type='text/javascript'>
$(document).ready(function(){
$('#login').modal('show');
});
</script>
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
Upvotes: 0
Reputation: 16301
Just echo a javascript snippet that triggers the modal like this:
echo "<script type='text/javascript'>
$(document).ready(function(){
$('#modalDivName').modal('show');
});
</script>";
N.B. Replace #modalDivName
with div id of your modal.
Upvotes: 1