PHP MAILING SCRIPT

The following script works and successfully sends an email and I receive the thank you echo, however the gender section of the form is not showing in the email that I receive.

Any help on what I am doing wrong as I would like to add more form fields such as a drop down menu

[php]

<?php //if "email" variable is filled out, send email if (isset($_REQUEST['email'])) {

//Email information
$admin_email = "[email protected]";
$email = $_REQUEST[‘email’];
$subject = $_REQUEST[‘subject’];
$comment = $_REQUEST[‘comment’];
$gender = $_REQUEST[‘gender’];

//send email
mail($admin_email, “$subject”, $comment, “From:” . $email);

//Email response
echo “Thank you for contacting us!”;
}

//if “email” variable is not filled out, display the form
else {
?>

Email:
Subject:
Message:

Gender: Female Male
       <input type="submit" value="Submit" />
<?php } ?> [/php]

Where are you adding gender to the mail body?

Sorry I am not sure what you mean?

You said you wanted the gender in the email message. Where are you adding the gender to the body of the email?

When the user selects their gender, I want that this information to be sent to the $admin_email along with all the other data which is being sent successfully.

The gender is in the form

I want the gender to be inside the message sent by the user. Do I need to put the gender variable inside line 20?

It needs to be apart of the mail body that is sent. Currently. you are only sending the persons comments. If you want more, you need to make a variable to store the content and add to it what you want sent in the email.

[php]

<?php //if "email" variable is filled out, send email if (isset($_REQUEST['email'])) {

//Email information
$admin_email = "[email protected]";
$email = $_REQUEST[‘email’];
$subject = $_REQUEST[‘subject’];
$comment = $_REQUEST[‘comment’];
$likeit = $_REQUEST[‘likeit’]);

$message = "Hello!

Your contact form has been submitted by:

email: $email
subject: $subject
Like the website? $likeit
Comments: $comment
";

//send email
mail($admin_email, “$subject”, $comment, “From:” . $email);

//Email response
echo “Thank you for contacting us!”;
}

//if “email” variable is not filled out, display the form
else {

?>

Email:
Subject:
Message:

Do you like this website? Yes No Not sure

       <input type="submit" value="Submit" />
<?php } ?> [/php]

So, now you have the new variable, but you are still using $comment as the body of the email message.

Still not working. I have now inputted
//send email
mail($admin_email, $message);

<?php //if "email" variable is filled out, send email if (isset($_REQUEST['email'])) { $admin_email = "[email protected]"; //Email information $email = $_REQUEST['email']; $subject = $_REQUEST['subject']; $comment = $_REQUEST['comment']; $likeit = $_REQUEST['likeit']); $message = "Hello! Your contact form has been submitted by: email: $email subject = $subject; Like the website? $likeit Comments: $comment "; //send email mail($admin_email, $message); //Email response echo "Thank you for contacting us!"; } //if "email" variable is not filled out, display the form else {

Use code tags, there is a reason we have them.

http://www.w3schools.com/php/func_mail_mail.asp

It is now working.

Thanks for all your help.

Kind regards
Sam

Sponsor our Newsletter | Privacy Policy | Terms of Service