This question already has answers here :
There are multiple ways to handle it.
1) Please write below code after mail sent successfully.
if(!$retval->Send()) {
header("Location: http://www.example.com");
exit;
}
2) If that does not work for you, use a meta refresh method:
if(!$retval->Send()) {
$to = "http://www.example.com";
$url = $to;
print "<meta HTTP-EQUIV=Refresh CONTENT=\"5; URL=$url\">";
print "Thank you for your message.";
exit;
}
3) You can use a cookie also.
To use cookie,you have to create one token which have value of current timestamp and whenever you create cookie with also current timestamp and then compare both variable when page refresh. but cookies has previous timestamp and and token has current timestamp then it will not match.
$token = time();
setcookie('formToken', $token, time() + 3600);
if(isset($_POST['submit'])){
if($_POST['token'] != $_COOKIE['formToken']){
// die("Sorry");
$error_list .= '<li>You can not submit this form twice.</li>';
echo $error_list;
echo 'Thank you, your message has been sent. You do not need resubmit it again.';
exit;
}
Source
Php mail function sends email every time page is refreshed, Redirect to ?sent=1 without sending any output. And check One solution is to redirect to the same page or to a different page on success full completion. ie, Every time I send an email, Mail sends it twice. This can be annoying to the recipients and I'd like to resolve it. The recipient receives two emails and I sent one so there is a duplicate each time at their end. Using hotmail account on my end. Thanks in advance
You need to check submit
if (isset($_POST['submit'])) {
}
So your code is :
if (isset($_POST['submit'])) {
$to = "abc.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:mithlesh@rightturn.co.in \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
}
Why does Outlook email seem to 'reboot'or refresh several , Every time I log in to check my email (Outlook now as the Hotmail pages have gone to cyber heaven or ****) it refreshes the inbox several times before settling down to become readable. Email; /; Sending, receiving, and reading email If Microsoft will not fix this problem for customers who use outlook You can't. There's nothing we can do -- except to make the blog "private access only." The reason is simple -- we're on their free service so we have to operate on their terms.
Mostly mail sending happens after particular event or activity just like form-submit or button-click.. you need to design form with relevant fields.. then you can use isset() or !empty() for $_POST array
if(!empty($_POST)){
$to = "abc.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:mithlesh@rightturn.co.in \r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
}
One of my gmail accounts won't stop reloading., Every time I try to open my gmail it won't stop reloading, I can't even click Any solution? Anything I click causes Gmail inbox page to refresh. What if the page content is updated regularly and you need to dynamically schedule email sending of an updated page after a certain event? For example, the web page is loaded every day and you need to automate sending a daily report that must be sent only after the editor approves it.
put this code in starting of your php code outside isset submit button
if(empty($_SESSION['key']) && !isset($_SESSION['key'])){
$randomkey = rand(0,99999);
$mykey = $_SESSION['key'] = $randomkey
}
It set Session a unique random key. now in form field take one hidden field
<input type="hidden" name="key" value="<?=$mykey?>">
Now On Submit
First Check Current $mykey
Matches With Hidden Variable
After Performing Certain Action Unset $mykey
So it prevent user adding data multiple times by Refreshing the page.
I hope it Helps... :-)
How to stop auto-reload/refresh?!!!, Send feedback on. Ok, I was able to deal with the auto-refreshing of tabs that would Heck, I'm scared as I type this that I may auto-refresh this page and lose my post. Likewise, if I open in it a side tab - you can only focus on one thing at a time. You'll receive email notifications for new posts at. For every request, it will add the Access-Control-Allow-Origin: * header to the response. It tricks the browser, and overrides the CORS header that the server has in place with the open wildcard
Refresh page after sending, Support » Plugin: Very Simple Contact Form » Refresh page after sending Firstly, after sending the e-mail, if the page is refreshed, the message appears as if not sent and I haven't used the above cloud storage for some time and the system has changed. Please advise if you have problems to download the images. WPBeginner is a free WordPress resource site for Beginners. WPBeginner was founded in July 2009 by Syed Balkhi.The main goal of this site is to provide quality tips, tricks, hacks, and other WordPress resources that allows WordPress beginners to improve their site(s).
Enable Extract Refresh Scheduling and Failure Notification, Tableau Server is configured to send email messages when extract refreshes fail. Go to the General tab of the Settings page for the site you want to configure for To configure embedded credentials on a multi-site server, select Manage All Sites has failed, and suggests the reason for the failure and possible solution. For years, numerous studies have found that most people spend about 28% of their time each day on email. While newer studies show that collaborative tasks like email, chat, calls, and meetings take up 80% of most peoples’ days. Unfortunately, few of us are judged on our ability to send emails and receive emails.
Essential SharePoint 2007: A Practical Guide for Users, , reports are static, but views are updated every time you refresh the web page. It helps manage problems (a friend calls those opportuni- ties) and their resolutions. It can automatically send email when an issue is assigned, and it keeps a Burner Emails lets you create a custom, unique email address each time you need to provide your email address to a company. Each generated email address forwards the message you receive to your personal email account. If at any time you want to stop receiving email sent to that address, just turn off the email address in the extension.
Comments What dont you put this within if(isset($_POST))? @MagnusEriksson, sorry my friend. It was showing some error, net problems. Multiple comment was never my intensn sir can u tell me how to used cookies the above code is not working Please show updated code. $to = "abc.com"; $subject = "This is subject"; $message = "<b>This is HTML message.</b>"; $message .= "<h1>This is headline.</h1>"; $header = "From:mithlesh@rightturn.co.in \r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html\r\n"; $retval = mail ($to,$subject,$message,$header); if( $retval == true ) { echo "Message sent successfully..."; }else { echo "Message could not be sent..."; } if user reload's the page POST data is still have $_POST['submit']
So Above Code is executed whenever the user reloads Then you have to use Ajax sir when i run this code is not working Can you please show me your Form ? or clear the $_POST = array()
after send After refreshing Page still have post data In your code, you have not used form handling or post-array.. you have to check it first in any php tutorial