Questions about repeated submission by phpmailer

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.