0
Good evening, I have a contact form that’s working perfectly. However, after sending the email, the page turns white and I don’t have a feedback message. I’d like to display a modal with the message. Just follow my code:
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$cpf = $_POST['cpf'];
$moeda = $_POST['moeda'];
$valor = $_POST['valor'];
$local = $_POST['local'];
$formcontent=" Nome: $nome \n Email: $email \n CPF: $cpf \n Moeda: $moeda \n Valor: $valor \n Local: $local";
$recipient = "[email protected]";
$subject = "Contato Delivery SP";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
if ($formcontent == 1){
echo "<script>$('#form-modal').modal('show')</script>";
}else{
echo "<script>$('#form-modal-2').modal('show')</script>";
}
?>
Okay, but what’s stopping you from doing that? Where’s the modal code? Is it bootstrap? Jquery UI?
– mau humor
@user5978 Yes. Bootstrap. The modal is right on the index.php page, I can call it from the console normally. But when sending the form, instead of opening the modal, open the empty page of sendmail.php (which is the page with this code from above)...
– Amanda Vieira
But where is this modal? in the form? When you send data via form (without ajax) the content of the page is "lost". Put the modal HTML (and the related library inclusion and dependencies) above the <?php... of the code you posted. I think it will work there ...
– mau humor
That line here doesn’t make much sense.
if ($formcontent == 1){
- Surely it will never be one, for it is the text of the message.– Bacco