Not sure whats wrong here the error report says line 9, but when I look the code does not match.
The Error Message :
Parse error: syntax error, unexpected T_STRING, expecting '{' in /home/hletf/public_html/mailform.php on line 9
Forgive the Tables Please.
HTML FORM CODE :
<form id="form1" name="form1" method="post" action="mailform.php">
<table width="90%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="48%"><div align="right"><h3>Name:</h3></div></td>
<td width="52%"><input type="text" name="NAME" id="NAME" /></td>
</tr>
<tr>
<td><div align="right"><h3>Email:</h3></div></td>
<td><input type="text" name="EMAIL" id="EMAIL" /></td>
</tr>
<tr>
<td><div align="right"><h3>Comment:</h3></div></td>
<td><textarea name="COMMENT" id="COMMENT" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td>
<input type="image" name="SUBMIT" id="SUBMIT" src="images/submit_button.jpg" width="81" height="23" />
</td>
</tr>
</table>
</form>
MAILFORM.PHP :
<?PHP
define('kOptional', true);
define('kMandatory', false);
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('track_errors', true);
function DoStripSlashes($fieldValue) {
// temporary fix for PHP6 compatibility - magic quotes deprecated in PHP6
if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) {
if (is_array($fieldValue) ) {
return array_map('DoStripSlashes', $fieldValue);
} else {
return trim(stripslashes($fieldValue));
}
} else {
return $fieldValue;
}
}
function FilterCChars($theString) {
return preg_replace('/[\x00-\x1F]/', '', $theString);
}
function CheckEmail($email, $optional) {
if ( (strlen($email) == 0) && ($optional === kOptional) ) {
return true;
} elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
return true;
} else {
return false;
}
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$clientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$clientIP = $_SERVER['REMOTE_ADDR'];
}
$FTGNAME = DoStripSlashes( $_POST['NAME'] );
$FTGEMAIL = DoStripSlashes( $_POST['EMAIL'] );
$FTGCOMMENT = DoStripSlashes( $_POST['COMMENT'] );
$FTGSUBMIT = DoStripSlashes( $_POST['SUBMIT'] );
$validationFailed = false;
# Fields Validations
if (!CheckEmail($FTGEMAIL, kMandatory)) { $validationFailed = true; }
# Redirect user to the error page
if ($validationFailed === true) {
header("Location: http://www.glustik.com/error.html");
}
if ( $validationFailed === false ) {
# Email to Form Owner
$emailSubject = FilterCChars("OMG - Test");
$emailBody = "NAME : $FTGNAME
"
. "EMAIL : $FTGEMAIL
"
. "COMMENT : $FTGCOMMENT
"
. "SUBMIT : $FTGSUBMIT
"
. "";
$emailTo = 'James <james@glustik.com>';
$emailFrom = FilterCChars("$FTGEMAIL");
$emailHeader = "From: $emailFrom
"
. "MIME-Version: 1.0
"
. "Content-type: text/plain; charset=\"UTF-8\"
"
. "Content-transfer-encoding: 8bit
";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
# Redirect user to success page
header("Location: http://www.glustik.com/thanks.html");
}
?>