Forum Moderators: coopster
I get this error message in both IE and Firefox:
"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/content/r/o/b/robertnking/html/gfi/send_email.php on line 36"
<?php
function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
header("Location: contact.php?status=0");
}
// 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])) {
header("Location: contact.php?status=0");
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
die ("Invalid email address");// 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])) {
header("Location: contact.php?status=0");
}
}
}
return $email;
}
function escape_val($string) {
$string = str_replace(array('"',"<",">"),
array(""","<",">"), $string);
return $string;
}
$check_email = check_email_address($_REQUEST['email']);
$name = escape_val($_REQUEST['name']);
$message = escape_val($_REQUEST['message']);
$time = date('l dS \of F Y h:i:s A');
$email_subject = "New contact message from ".$site_name."";
if(mail($admin_email,$email_subject,$message,
"From:$check_email,Reply-to:$check_email")) {
header("Location: contact.php?status=1");
exit;
} else {
header("Location: contact.php?status=0");
}
?>
be sure to check out the Library [webmasterworld.com] and Charter [webmasterworld.com] links for the PHP forum for various references and resources.