-4
不知道錯誤報告說第9行有什麼問題,但是當我看起來代碼不匹配時。PHP表單 - 無驗證的簡單表格
錯誤消息:
解析錯誤:語法錯誤,意想不到T_STRING,期望 '{' 在第9行
/home/hletf/public_html/mailform.php原諒表請。
HTML表單代碼:
<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\n"
. "EMAIL : $FTGEMAIL\n"
. "COMMENT : $FTGCOMMENT\n"
. "SUBMIT : $FTGSUBMIT\n"
. "";
$emailTo = 'James <[email protected]>';
$emailFrom = FilterCChars("$FTGEMAIL");
$emailHeader = "From: $emailFrom\n"
. "MIME-Version: 1.0\n"
. "Content-type: text/plain; charset=\"UTF-8\"\n"
. "Content-transfer-encoding: 8bit\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
# Redirect user to success page
header("Location: http://www.glustik.com/thanks.html");
}
?>
標識線15條,並顯示哪些文件正在拋出錯誤。 – nickb
錯誤信息如何?或者關於問題是什麼的一些指導。 – Pete855217
對不起,它要麼下滑了,要麼因爲它沒有匹配,我不認爲它是相關的。我在上面添加了錯誤消息。 – Varazi