简体   繁体   中英

How to make a contact form send a confirmation email to the user?

This is what i have so far..

 $full_name = $_REQUEST['full_name'] ;         
 $company = $_REQUEST['company'] ;       
 $abn = $_REQUEST['abn'] ;     
 $customer_number = $_REQUEST['customer_number'] ;     
 $about = $_REQUEST['about'] ;     
 $areacode = $_REQUEST['areacode'] ;     
 $telephone = $_REQUEST['telephone'] ;         
 $email = $_REQUEST['email'] ;     
 $message = $_REQUEST['message'] ;     
 $body =" Full Name: ".$full_name."\n

Company: ".$company."\n                 
ABN: ".$abn."\n    
Customer Number: ".$customer_number."\n
About: ".$about."\n       
Area Code: ".$areacode."\n      
Telephone: ".$telephone."\n     
Email: ".$email."\n                     
Message: ".$message;

$to = "$email";

 mail( "info@rentforbusiness.com.au", "Contact Us Form", $body, "From: $email" );

就像您为自己做的一样。

mail($email, "Thanks For Resistering", $a_thank_you_message, "From: info@rentforbusiness.com.au" );

Create a table in database. It should contains fields:

  • id (auto increment)
  • email
  • message
  • confirmation

When user posts the form, don't send mail to your email, instead of it you need to create random confirmation code (using uniqid for example):

$confirmation = uniqid();

Then add user email, message text and confirmation code to table and send email to user:

$url = "http://".$_POST["SERVER_NAME"].
  "/confirmation.php?confirmation=$confirmation'>";
mail($email, "Confirmation", 
 "Please press the following link to confirm your message: 
 <a href='http://$url'>confirm</a>.");

In confirmation.php file use $_GET["confirmation"] variable, search for matching record in the table, get email and message from it and send this data to your email. You can remove entry from database after it if you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM