walrus111 Posted July 23, 2008 Share Posted July 23, 2008 Hi Guys. I have this simple php form script below that works fine but the email it sends out only lists the text that the sender types in and doesn't include subheadings for each form field. <?php $sendTo = "[email protected]"; $subject = "John's enquiry form"; $from_address = @$HTTP_POST_VARS['email']; $headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $body .= $_POST["name"]."\n\n"; $body .= $_POST["company"]."\n\n"; $body .= $_POST["email"]."\n\n"; $body .= $_POST["phone"]."\n\n"; $body .= $_POST["enquiry"]; mail($sendTo, $subject, $body, $headers); ?> How do I modify the script to include subheadings so I know what each field is when I receive the email. Any help much appreciated. Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/ Share on other sites More sharing options...
iezugod Posted July 23, 2008 Share Posted July 23, 2008 Can you post a sample of the email output? Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597108 Share on other sites More sharing options...
vbnullchar Posted July 23, 2008 Share Posted July 23, 2008 what do you mean by sub-heading? Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597113 Share on other sites More sharing options...
walrus111 Posted July 23, 2008 Author Share Posted July 23, 2008 Thanks for the reply. Here is the response from the form. John John Pty Ltd [email protected] 02 9999 9999 (work) my enquiry is about... This is how I want it to be outputted to my email: Name: John Company: John Pty Ltd Email: [email protected] Phone: 02 9999 9999 (work) Enquiry: My enquiry is about... Hope this helps. Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597121 Share on other sites More sharing options...
iezugod Posted July 23, 2008 Share Posted July 23, 2008 I thought that might be the case. An easy way: $body .= "Name: " . $_POST["name"]."\n\n"; $body .= "Company: " . $_POST["company"]."\n\n"; $body .= "Email: " . $_POST["email"]."\n\n"; $body .= "Phone: " . $_POST["phone"]."\n\n"; $body .= "Enqury: " . $_POST["enquiry"]; Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597122 Share on other sites More sharing options...
vbnullchar Posted July 23, 2008 Share Posted July 23, 2008 you forgot to include it.. see below <?php $sendTo = "[email protected]"; $subject = "John's enquiry form"; $from_address = @$HTTP_POST_VARS['email']; $headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n"; $body .= "Name: ".$_POST["name"]."\n\n"; $body .= "Company: ".$_POST["company"]."\n\n"; $body .= "Email: ".$_POST["email"]."\n\n"; $body .= "Phone: ".$_POST["phone"]."\n\n"; $body .= "Inquiry: ".$_POST["enquiry"]; mail($sendTo, $subject, $body, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597123 Share on other sites More sharing options...
walrus111 Posted July 23, 2008 Author Share Posted July 23, 2008 Thanks for all your help Vbnullchar. It's now working like a charm. Cheers. Link to comment https://forums.phpfreaks.com/topic/116113-solved-defining-sub-headings-in-php-form-response/#findComment-597139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.