Jump to content

[SOLVED] Defining sub-headings in php form response


walrus111

Recommended Posts

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.

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.

 

 

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"];

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.