This code is great, thanks for the help but there is one problem. I want users to have the option of subscribing to my email not forcing them too or giving them a message saying they have to subscribe to submit their info. I'm trying to get the code to simply tell me wether or not the checkbox has been clicked so i can add them to my distribution list.
Thanks for the help thus far though!
Sorry, I misunderstood your problem/question.
1: Set the checkbox name to "subscribe" on the form, and make sure the submit name is set to "submit".
2: Set the checkbox "value when checked" to 1. (The user above mentioned a boolean check, and that works fine as well. I use a check value here as it makes the code very easy to understand)
Now try this idea:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$question = $_POST['question'];
if ($_POST['subscribe'] == 1) {
$subscribe = "Yes";
} else {
$subscirbe = "No";
}
if (isset($_POST['submit'])) {
$where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));
mail("xxxxxxx@xxxxxxx.org","Website Contact Form submission","Form data:
Mathew, you have a question from: $name
Email: $email
Phone Number: $phone
Their question reads: $question
Would like to subscribe: $subscribe
");
include("confirm.html");
}
?>
NOTE: I still include (and recommend) that you check to see if "submit" is set before processing the form, but I took out the "else" that said they had to subscribe.