Jump to content

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


toolman
Go to solution Solved by Barand,

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 = 'me@me.com';
        $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");
    }
 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.