I've got a form to email problem,
I've used this script before, and it's worked fine, only I've added in three drop select boxes, I don't know if this is what is causing the problem or not, any enlightenment on why it will not send the email would be great (It goes to the failed send deliverymessage)
I am running it from a different server from usual, but as it does form to email already with no problems, I couldn't figure out why it would spit the dummy over this.
The form is a pretty basic thing, and it error checks ok, so it's not broken up to that point.
Do I need to be defining an array with the select boxes - could this be my problem?
At the moment they are just like this (inside a print command- hence backslashes)
I keep wondering if they should be name=\"browsertype[]\"
and then use an implode to put them into the email.
Thanks.
----------------------------------------
Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..
I've used this script before, and it's worked fine, only I've added in three drop select boxes, I don't know if this is what is causing the problem or not, any enlightenment on why it will not send the email would be great (It goes to the failed send deliverymessage)
I am running it from a different server from usual, but as it does form to email already with no problems, I couldn't figure out why it would spit the dummy over this.
Code:
<?php
//check if the form has been submitted
if (!isset($_POST[$Submit])) {
show_form($name, $email, $comments, $errormessage);
}
else if (isset($_POST[$Submit])) {
//if it has do the email processing
//trim trailing whitespace
$name=trim($name);
$email=trim($email);
$comments=trim($comments);
//do error checking
if (!eregi("^[a-zA-Z0-9_\-\.\-\\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
{
$errormessage = "<b><font color=\"red\"> The email field is empty or invalid. </font></b>";
show_form($name, $email, $comments, $errormessage);
//echo "You have entered an invalid email address. Please return to the previous page and try again.";
exit;
}
//set headers for the email to display and format email content
$headers .= "From: Domain: Webmaster Query <name@domain.com>\n";
$headers .= "Reply-To: ".$email."\n";
$headers .= "X-Sender: <name@domain.com>\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: <name@domain.com>\n";
$toaddress = "name@domain.com";
$mailcontent = "Customers Name: ".$name."\r\n"
."Customers Email: ".$email."\r\n"
."Customers Browser Type: ".$browsertype."\r\n"
."Customers Operating System: ".$os."\r\n"
."Customers Query Type: ".$querytype."\r\n"
."Customers Comments: ".$comments."\r\n"
."Contact Customer to follow up: ".$yes."\r\n";
//check if the email sends ok
if(mail($toaddress,"Comments from ".$name,stripslashes($mailcontent),$headers) == true) {
$deliverymessage = "<b>Thank you, your feedback has been sent.</b>";
no_form($deliverymessage);
}
else {
//if it doesn't spit out error message
$deliverymessage = "<b>There has been a server error with your request.</b> Please press the back button on your browser and try again.";
no_form($deliverymessage);
}
}//end of isset submit
?>
The form is a pretty basic thing, and it error checks ok, so it's not broken up to that point.
Do I need to be defining an array with the select boxes - could this be my problem?
At the moment they are just like this (inside a print command- hence backslashes)
Code:
<td>Type of browser:</td>
<td> <label>
<select name=\"browsertype\" id=\"browsertype\">
<option selected>Choose your browser</option>
<option value=\"IE\">Internet Explorer</option>
<option value=\"Firefox\">FireFox</option>
<option value=\"Opera\">Opera</option>
<option value=\"Mozilla\">Mozilla</option>
<option value=\"Other\">Other</option>
</select>
</label>
</td>
I keep wondering if they should be name=\"browsertype[]\"
and then use an implode to put them into the email.
Thanks.
----------------------------------------
Sometimes, when my code just won't behave, I take it outside and make it listen to britney spears music, and when it comes back it's really well behaved. I wonder if it's suffering from post tramatic stress syndrome now..