基本窗体处理程序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基本窗体处理程序相关的知识,希望对你有一定的参考价值。

processes contact form input and produces an auto reply
  1. <?php
  2.  
  3. $fields = array();
  4. $fields{"Name"} = "Name";
  5. $fields{"Email"} = "Email";
  6. $fields{"Message"} = "Message";
  7.  
  8. $from = $_REQUEST['Email'] ;
  9. $name = $_REQUEST['Name'] ;
  10. $headers = "From: $from";
  11. $subject = "NCCDC Web contact -- From contact page";
  12.  
  13. $body = "WEB CONTACT FROM NCCDC We have received the following information: "; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s ",$b,$_REQUEST[$a]); }
  14.  
  15. /*Second email */
  16. $headers2 = "From: [email protected]";
  17. $subject2 = "Thank you for contacting NCCDC";
  18. $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usually within 48 hours. If you have any more questions, please consult our website at www.pdxchild.org";
  19. $autoreply .= " You Wrote: ".$_REQUEST["Message"];
  20.  
  21. if($from == '') {print "You have not entered an email, please go back and try again";}
  22. else {
  23. if($name == '') {print "You have not entered a name, please go back and try again";}
  24. else {
  25. $send = mail($to, $subject, $body, $headers);
  26. $send2 = mail($from, $subject2, $autoreply, $headers2);
  27. if($send)
  28. {header( "Location: ../thankyou/" );}
  29. else
  30. {print "We encountered an error sending your mail, please notify [email protected]"; }
  31. }
  32. }
  33. ?>

以上是关于基本窗体处理程序的主要内容,如果未能解决你的问题,请参考以下文章