Posted By

dmautz1 on 09/22/09


Tagged

form email post


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

HelloKit


HTML Email Form $_POST Contents


 / Published in: PHP
 

I use this to activate basic forms for clients. Just make sure your form input names are named appropriately. Any inputs such as phone or fax that are separated into different inputs should have the same name.

  1. $headers = "Content-Type: text/html; charset=iso-8859-1\n";
  2. $to = "[email protected]";
  3. $subject = "New Form Submission";
  4.  
  5. // set html email content
  6. $text = "<html><body>The form details are listed below:<br><br><table>";
  7.  
  8. // loop through POST
  9. foreach($_POST as $key => $value)
  10. {
  11. if(is_array($value)){
  12. if(strstr($key, "phone") || strstr($key,"fax")){
  13. $value = implode("-",$value);
  14. }else{
  15. $value = implode(",",$value);
  16. }
  17. }
  18. $text .= "<tr><td>".$key."</td><td>".$value."</td></tr>";
  19. }
  20.  
  21. $text .= "</table></body></html>";
  22.  
  23. // you may need to add some form inputs manually depending on your setup
  24.  
  25. //email admin to notify of new submission
  26. mail($to, $subject, $text, $headers);

Report this snippet  

You need to login to post a comment.