Jump to content

how can I include fields in the body of an email?


toolman

Recommended Posts

Hi,

 

I have the following script which sends an email, but it only displays the &message in the email.

 

I would like to include the $from_name, $from_email and $telephone in the email as well.

 

How would I do this?

 

Thanks!

 

 

 
  if($_POST){
        $to = '[email protected]';
        $subject = 'Signup';
        $from_name = $_POST['name'];
    $company = $_POST['company'];
        $from_email = $_POST['email'];
    $telephone = $_POST['telephone'];
        $message = $_POST['message'];
        $robotest = $_POST['robotest'];
        if($robotest)
            $error = "You are a gutless robot.";
        else{
            if($from_name && $from_email && $message){
                $header = "From: $from_name <$from_email>";
                if(mail($to, $subject, $message, $header))
                    $success = "You are human and your message was sent!";
                else
                    $error = "You are human but there was a problem sending the e-mail.";
            }else
                $error = "All fields are required.";
        }
        if($error)
            echo '<div class="msg error">'.$error.'</div>';
        elseif($success)
            header ("location: contactthanks.php");
    }
 

Hi,

 

I'm not sure if I should open a new post for this, but I have two forms on the same page, one with an extra field and the details get submitted to a different email address.

 

What would be the best way to have two lots of the above code on the page?

 

Thanks

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.