Jump to content

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 = "john@xxx.com.au";

$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

 

john@xxx.com.au

 

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: john@xxx.com.au

 

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 = "john@xxx.com.au";
$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);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.