Phpmailer repeated submission. Blog. csdn. netdaydreamingboyarticledetails6299495 ?? Phpif (isset ($ _ POST [submitted]) {require (PHPM
Phpmailer repeated submission. Http://blog.csdn.net/daydreamingboy/article/details/6299495 I want to send a form of a page in the form of mail with PHPMailer to the specified mailbox, for fear of repeated submission, do not know whether there is this expert? ? Php if (isset ($ _ POST ['submitted']) {require ('phpm
Phpmailer repeated submission.
Http://blog.csdn.net/daydreamingboy/article/details/6299495
I want to use PHPMailer to send a form on a page to a specified mailbox in the form of an email. I am afraid someone will submit the form repeatedly. Do you have any experts in this field?
If (isset ($ _ POST ['submitted']) {
Require ('phpmailer/class. PHPMailer. php ');
$ Mail = new PHPMailer ();
// Does not contain Form Verification
If (! Empty ($ _ POST ['Contact ']) &! Empty ($ _ POST ['subobject']) &
! Empty ($ _ [this article comes from the Internet (http://www.68idc.cn)] POST ['content']) &! Empty ($ _ POST ['from']) {
$ Address = $ _ POST ['Contact '];
$ Mail-> Subject = $ _ POST ['subobject'];
$ Mail-> Body =$ _ POST ['content'];
$ Mail-> FromName = $ _ POST ['from'];
} Else {
Echo'Complete all!
';
Exit ();
}
$ Mail-> IsSMTP ();
$ Mail-> Host = "smtp.163.com ";
$ Mail-> SMTPAuth = true;
$ Mail-> Username = "your_mail@163.com ";
$ Mail-> Password = "your_password ";
$ Mail-> Port = 25;
$ Mail-> From = "your_mail@163.com ";
$ Mail-> AddAddress ("$ address", "my friend ");
If (! $ Mail-> Send ()){
Echo"
Failed to send email!
";
Echo "error cause:". $ mail-> ErrorInfo;
Exit ();
} Else {
Echo"
Email sent successfully!
";
}
}
?>
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
Use PHPMailer to send emails
------ Solution ----------------------
When you submit a database record that has been submitted, you can use the email address to determine whether the record is repeated.
------ Solution ----------------------
Session_start ();
$ Key = md5 (serialize ($ _ POST ));
If (empty ($ _ SESSION ['last']) $ _ SESSION ['last'] = $ key;
Else if ($ _ SESSION ['last'] = $ key) die ('reseller not allowed ');
// Send an email
1. You cannot invalidate the submit button only because you may need to send multiple emails. Besides, regular form submission produces new pages and does not invalidate them.
2. It is common to send multiple emails to one email address instead of the target email address.
3. Repeat can be considered only when the two submissions are completely the same