Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表单-没有验证的简单表单_Php_Html_Forms - Fatal编程技术网

PHP表单-没有验证的简单表单

PHP表单-没有验证的简单表单,php,html,forms,Php,Html,Forms,不确定这里出了什么问题错误报告说第9行,但当我看代码不匹配 错误消息: 分析错误:语法错误,意外的T_字符串,第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"

不确定这里出了什么问题错误报告说第9行,但当我看代码不匹配

错误消息:
分析错误:语法错误,意外的T_字符串,第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 <james@glustik.com>';
   
  $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");

}

?>

使用此函数更改您的函数:

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; 
    } 
}   

识别第15行,并显示哪个文件抛出了错误。错误消息如何?或者关于问题是什么的一些指导。很抱歉,我忘记了,或者因为它不匹配,我认为它不相关。我已经在上面添加了错误消息。