ok, I'm going to paste my form processing script and my validation include file, this stupid regex is giving me a headache
verify.php
<?php
function verify_email($email) {
return (preg_match("/^\w[^@\s]*\w@\w([\w\.]*\w)?\.\w{2,}$/", $email));
}
function verify_phone($phone) {
echo "PHONE IS: ".$phone;
$phone = trim($phone);
return (preg_match("^([\s\(])?[1-9]{3}([\-\s\)\.])?[0-9]{3}([\-\s\.])?[0-9]{4}([\-\s\.])?\w{0,4}([\-\s\.])?[0-9]{0,4}$", $phone));
}
function verify_text($text){
return (preg_match("^([1-zA-Z0-1@.\s]{1,1000})$", $text));
}
?>
send.php
<?
//email handling form for contact form, resume form, and support form
//contact form emails sales contact info
//resume form emails name/email/phone and resume attachment
//support form not created yet, will email image/screnenshot/etc.,
$path="Gnossos Software::Contact Us";
include ("files/header.php");
include ("files/verify.php");
$formtype = stripslashes($_POST['formtype']);
//for contact form
if ($formtype == "contact"){
$subject = "SALES, subject: " . $_POST['subject'];
$to = "blank@blank.com";
//if(!verify_email($_POST['email'])){
// echo "bad email";
// exit;
//}
if(!(verify_phone(stripslashes($_POST['phone'])))){
echo "bad phone number";
exit;
}
}//end contact if
//these are common to all form types
foreach ($_POST AS $key => $value){
$message .= $key."=".$value."\n";
}
$headers = "From: $_POST['email']\r\n";
$from = stripslashes($_POST['name'])."<".stripslashes($_POST['email']).">";
if(!verify_email($_POST['email'])){
echo "bad email";
exit;
}
//end common actions
//this handles both support and resume submission as both involve file attachments
//to handle resume submission form
if(($formtype == "resume") or ($formtype == "support")){
//to handle resume form
if($formtype == "resume"){
$subject = "RESUME, subject: " . $_POST['name'];
$to = "blank@blank.com";
echo "TEST\n";
}
//to handle support form
if($formtype == "support"){
$subject = "SUPPORT: subject: ";
$to = "blank@blank.com";
if(!verify_phone(stripslashes($_POST['phone']))){
echo "bad phone number";
exit;
}
}
echo "TO: ".$to."\n";
echo "FORM: ".$formtype."\n";
$tmp_name=$_FILES['file']['tmp_name'];
$type = $_FILES['file']['type'];
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$headers = "From: $_POST['email']";
if (file_exists($tmp_name)){
if(is_uploaded_file($tmp_name)){
$file = fopen($tmp_name, 'rb');
$data = fread($file, filesize($tmp_name));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}--\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}'\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data ."\n\n" .
"--{$mime_boundary}--\n";
}//end is uploaded
}//end file exists
}//end test
//common information to all forms
echo "<div id=\"content\">";
echo "<div id=\"leftcont\">";
if(mail($to, $subject, $message, $headers)){
header("Refresh: 3; URL=http://www.gnossos.com/test/testing.php");
echo "<h4 style=\"text-align:center\">Your message was sent, someone will contact you shortly. <br />\n".
"You will be redirected to the home page in 5 seconds...</h4>";
echo "";
} else {
header("Refresh: 3; URL=http://www.gnossos.com/test/testing.php");
echo "<h4 style=\"text-align:center\">Your message failed, please contact the<a
href=\"mailto:blank@blank.com\">
webmaster</a><br />You will be redirected to the home page in 5 seconds...</h4>";
echo "";
}
echo "</div><!--end leftcont-->";
include ("files/footer.html");
?>
there has got to be something wrong with the way I am handling this and it's probably dead simple, but I just am not seeing it at all.
thanks much for any insights