Hey guys,
I have this parse error:
[b]Parse error: parse error, unexpected ‘{‘ in /srv/www/htdocs/pages/mail.php on line 12
for the following code:
[code]
<?php
$name = $_POST[‘name’];
$from = $_POST[’email’];
$contact = $_POST[‘contact’];
$message = $_POST[‘message’];
if ($name == “” || $from == “” || $message == “”) {
print “<script type=”text/javascript”>alert(“You must fill out all fields!”);location.href = “javascript:history.go(-1)”;</script>”;
} else {
[color=red][b]12 =>[/color][/b] if (!eregi(“^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$”,$email) {
print “<script type=”text/javascript”>alert(“Please enter a valid email address!”);location.href = “javascript:history.go(-1)”;</script>”;
} else {
switch ( $contact )
{
case general :
$to=”[email protected]”;
break;
case sales :
$to=”[email protected]”;
break;
case services :
$to=”[email protected]”;
default :
$to=”an error occurred”;
break;
}
$subject = ‘Email from ‘.$name.”;
$headers = ‘From: ‘.$from.” . “rn” .
‘Reply-To: ‘.$from.” . “rn” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);
print ‘<p style=”text-align: center; “>Your message was sent successfully</p>’;
print ‘<p style=”text-align: center; “>Thank you for using our contact page.</p>’;
print ‘<p style=”text-align: center; font-size: 10pt; “>Going back to contact page (or click <a href=”javascript:history.go(-1)”>here</a>)</p>’;
print ‘<META HTTP-EQUIV=”Refresh” CONTENT=”3; URL=javascript:history.go(-1)”>’;
}
}
?>
I don’t understand why. Maybe I just can’t see the error… can anyone else?
hamstar