[RESOLVED] problem with contact form email form send_form_email.php
i have a problem with my contact form. Everything seemed to work just fine, than i found two problems; the checkbox i inserted doesn't work yet, same as the subject. When i receive emails, they stay blanco. I have tried all kind of things but i still don't know what to do. I don't know much about HTML and I don't know how to change the code so it will work. I used a standard contact form I found on the internet... i changed a few things (I added 'subject' instead of 'telephone', I deleted 'last name', etc. and I added a checkbox...) I know I messed with the code..., but I seriously don't know how to fix it and make it work... hope someone can help me out.. already many thanks!
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "*****";
$email_subject = "******";
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
OK I tested this one out.
You need to replace these lines with your information:
$email_to = "[your email address goes here]";
$email_subject = "[this is the subject line that will show up in your inbox]";
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[your email address goes here]";
$email_subject = "[this is the subject line that will show up in your inbox]";
if (isset($_POST['newsletter'])) {
$check_msg = "i want to receive the newsletter";
} else {
$check_msg = "";
}
}
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be empty fields in the form you submitted.');
}
$error_message = "";
$email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
if(!eregi($email_exp,$email_from)) {
$error_message .= 'The email address you entered does not appear to be valid.<br />';
}
$string_exp = "^[a-z .'-]+$";
if(!eregi($string_exp,$name)) {
$error_message .= 'The name you entered does not appear to be valid.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'The message you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
Bookmarks