; switch($_POST['mailto']){ case '1': $to = 'info@carolinawoman.com'; $subject = 'General Information'; break; case '2': $to = 'ads@carolinawoman.com'; $subject = 'Advertising'; break; case '3': $to = 'articles@carolinawoman.com'; $subject = 'Editorial'; break; case '4': $to = 'update@carolinawoman.com'; $subject = 'Update'; break; case '5': $to = 'events@carolinawoman.com'; $subject = 'Events'; break; case '6': $to = 'classifieds@carolinawoman.com'; $subject = 'Classifieds'; break; case '7': $to = 'directory@carolinawoman.com'; $subject = 'Directory'; break; case '8': $to = 'circulation@carolinawoman.com'; $subject = 'Circulation'; break; case '9': $to = 'production@carolinawoman.com'; $subject = 'Web Site'; break; default: $to = 'info@carolinawoman.com'; $subject = 'Comments from carolinawoman.com'; } if(isset($_POST["Submit"])) { check_form(); // errs } else { show_form(); // no errs } function check_email($email) { if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. return false; } // Split it into sections to make life easier $email_array = explode("@", $email); $local_array = explode(".", $email_array[0]); for ($i = 0; $i < sizeof($local_array); $i++) { if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { return false; } } if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name $domain_array = explode(".", $email_array[1]); if (sizeof($domain_array) < 2) { return false; // Not enough parts to domain } for ($i = 0; $i < sizeof($domain_array); $i++) { if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { return false; } } } return true; } function check_name($name){ if (eregi("^[[:alpha:]]{2,}[[:space:]][[:alpha:]]{2,}$",$name)){ // If there are at least two letters separated by a space return true; } } function check_nocode($message){ if (eregi("^[[:alnum:]]}$",$message)){ return true; } } function check_form() { global $HTTP_POST_VARS, $error, $print_again; if (!check_nocode($_POST['comments'])){ // set err msg $error['nocode'] = true; $print_again = true; $msg.="No code allowed.
"; } if(!check_name($_POST['name'])) { // if no match, set err msg, same below for each field. $error['name'] = true; $print_again = true; $msg.="Please enter first and last name.
"; } if(!check_email($_POST['email'])) { $error['email'] = true; $print_again = true; $msg.="Invalid email!
"; } if($print_again) { show_form(); // correct errors and/or an empty form - display errs do not send } else // if all checks ok, ok to send mail { show_form(); $msg.="Thank you.
We will contact you shortly."; $sent = $msg; foreach ($_POST as $key=>$value) { $message.=$key.": " . $value . "\n"; } if ($msg == $sent){ $headers ="From: carolinawoman.com"; mail($to, $subject, $message, $headers); } } echo"$msg
"; } ?>

Thank you

Thanks! Your message has been sent.
We will respond to you shortly.