Forum Moderators: coopster
# Default error_header
$error_header = "<p>Please check below for the errors that have occured, Pease be sure to include the missing fields indicated before continueing</p><br>";
# error checking
if(!$_POST['name']) {
$error1 = '<p>Please Fill in the Name field</p>';
} /*check to make sure name is filled in, if not display error message on form as error1*/
if(!$_POST['email']) {
$error2 = '<p>Please fill in the email field</p>';
} /*check to make sure email is filled in, if not display error message on form as error2*/
if(!$_POST['request']) {
$error3 = '<p>Please fill in your request or comments</p>';
} /*check to make sure a suggestion is filled in, if not display error message on form as error3*/
if ($_POST['department'] == 'none') {
$error4 = '<p>Please select an area you would like to comment on<p/>';
}
if ($_POST['contactrequested'] == 1) $contactrequested = "Please contact me";
if(!$error1 &&!$error2 &&!$error3 &&!$error4)
$subjects = array(
"request",
"missy",
"cds",
"bookings",
"coments",
"web-site",
"fan-club"
);
$toaddresses = array(
"csd@mysite.com",
"missy@mysite.com",
"orders@mysite.com",
"missy@mysite.com",
"csd@mysite.com",
"pat@mysite.com",
"dee@mysite.com"
);
$toaddress = 'pat@mysite.com'; //default email
$subject = $_POST["messagetype"];
for($i=0; $i<count($subjects); $i++){
if(strcasecmp($subject,$subjects[$i])==0){
$toaddress = $toaddresses[$i];
break;
}
}
$mailcontent = 'Customer name: '.$name."\n"
.'Customer email: '.$email."\n"
.'Contact requested: '.$contactrequested."\n"
.'Department: '.$department."\n"
."Customer requests or comments: \n".$request."\n";
#$fromaddress = 'From: [email]contacts@mysite.com[/email]';
$fromaddress = 'contacts@mysite.com';
$sent = @mail($toaddress,$subject,$mailcontent,"From: Contact <$fromaddress>\r\n");
?>
<?php
require ('./inc/header.inc.php');
?>
#############################
the rest of the page is the html form. can anyone offer any suggestions on why this is not working
Pat
<select name="dept">
<option value="0">Requests</option>
<option value="1">Missy</option>
<option value="2">CDs</option>
<option value="3">Bookings</option>
<option value="4">Comments</option>
<option value="5">Web-Site</option>
<option value="6">Fan Club</option>
</select>Then when you process simply access the array slot.
$dept = $_POST['dept'];
mail($toaddresses[$dept],$subjects[$dept],$mailcontent,"From: Contact <$fromaddress>\r\n");
Hope that helps,
dc
# Default error_header
$error_header = "<p>Please check below for the errors that have occured, Pease be sure to include the missing fields indicated before continueing</p><br>";
# error checking
if(!$_POST['name']) {
$error1 = '<p>Please Fill in the Name field</p>';
} /*check to make sure name is filled in, if not display error message on form as error1*/
if(!$_POST['email']) {
$error2 = '<p>Please fill in the email field</p>';
} /*check to make sure email is filled in, if not display error message on form as error2*/
if(!$_POST['request']) {
$error3 = '<p>Please fill in your request or comments</p>';
} /*check to make sure a suggestion is filled in, if not display error message on form as error3*/
if ($_POST['department'] == 'none') {
$error4 = '<p>Please select an area you would like to comment on<p/>';
}
if ($_POST['contactrequested'] == 1) $contactrequested = "Please contact me";
if(!$error1 &&!$error2 &&!$error3 &&!$error4)
$department = array(
"missy",
"sales",
"bookings",
"customer_service",
"fan_club"
);
$toaddresses = array(
"missy"=> "missy@mysite.com",
"sales"=> "orders@mysite.com",
"bookings"=> "missy@mysite.com",
"customer_service"=> "csd@mysite.com",
"fan_club"=> "dee@mysite.com"
);
$toaddress = 'pat@mysite.com'; //default email
$subject = $_POST["messagetype"];
$dept = $_POST['department'];
$mailcontent = 'Customer name: '.$name."\n"
.'Customer email: '.$email."\n"
.'Contact requested: '.$contactrequested."\n"
.'Department: '.$dept."\n"
."Customer requests or comments: \n".$request."\n";
$fromaddress = 'contacts@mysite.com';
mail($toaddresses[$dept],$department[$dept],$mailcontent,"From: Contact <$fromaddress>\r\n");
?>
<?php
require ('./inc/header.inc.php');
?>
#######################
HTML part of the form
<fieldset class="department"><label class="department" for="department">
<p>Please help us direct your feedback by selecting a catagory you would
like to comment on?</p>
<p><? echo "<font color='red'>$error4</font>";?></p>
<select id="department" name="department" size="1">
<option value="none">Select a Department</option>
<option value="missy">Missy</option>
<option value="sales">Sales</option>
<option value="bookings">Bookings</option>
<option value="customer_service">Customer Service</option>
<option value="fan_club">Fan Club</option>
</select></label>
<br>
</fieldset>
#################################
Can anyone see what i'm missing
Pat
I checked and I think that you forgot to close the first if statement
if(isset($_POST['submit_form'])) { Also, try to always put brackets after the if statement, easier to debug afterwards
Therefore,
if ($_POST['contactrequested'] == 1) $contactrequested = "Please contact me"; if ($_POST['contactrequested'] == 1) {$contactrequested = "Please contact me";} Same problem occurs after
if(!$error1 &&!$error2 &&!$error3 &&!$error4)