Answer the question
In order to leave comments, you need to log in
How can I make sure that nothing happens on the screen after sending an email?
Good day.
Please tell me how to configure Phpmailer so that after clicking the "Send" button, nothing else happens except for sending the letter (it doesn't redirect me to other pages, no windows pop up, etc.).
At the moment, my settings_mail.php file says
if ($mail->send()){
header("Location: https://www.google.com/");
}
Answer the question
In order to leave comments, you need to log in
You need to hook the form's submit event and send an AJAX request when the form is clicked.
If you are using a framework, google "<framework name> AJAX Forms".
In any case, you need a basic understanding of JS (or in particular JQuery), then you can easily implement everything.
There are two options, it seems to me:
1) As already mentioned - use AJAX (the best option)
2) header('Location: '.$_SERVER['REQUEST_URI']);
- paste instead of redirecting to Google, so the page will simply reload
I suspect that you have a condition for displaying the form, like this
if ($mail->send()){
header("Location: https://www.google.com/");
} else {
// show html form
}
if ($mail->send()){
echo 'Thank! Your message has been sent!';
}
// show html form
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question