我收到以下错误:
PHP Parse错误:语法错误,第59行意外的文件结束
这是我的代码:
<?php
require_once("FormFunctions.php");
require_once("ValidationFunction.php");
$errors = array();
$message = "";
if (isset($_POST['submit'])){ // form was submitted
$username = trim($_POST["username"]);
$password = trim($_POST["password"]);
// validations
$fields_required = array("username", "password");
foreach($fields_required as $field){
$value = trim($_POST[$field]);
if (!has_presence($value)){
$errors[$field] = ucfirst($field) . " cannot be blank";
}
}
$field_max_length = array("username" => 10, "password" => 5);
foreach($fields_max_length as $field => $max){
$value = trim($_POST[$field]);
if (!max_length($value, $max)){
$errors[$field] = ucfirst($field) . " is too long";
if (empty($errors)){
// try to log in
if ($username == "CIS108" && $password == "PHP"){ // login successful
redirect_to("process1.php");
} else{ // login failed
$message = "Login failed! Username and password combination was incorrect.<br/>Please log in again.";
}
}
} else{
$message = "please log in.";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Two</title>
</head>
<body>
<h1>Third form login</h1>
<b><?php echo $message;?></b>
<b><?php echo form_errors($errors);?></b>
<form action="Form3.php" method="post">
First Name: <input type="text" name="first_name" value="" /><br />
Last Name: <input type="text" name="last_name" value="" /><br />
Username: <input type="text" name="username" value="" /><br />
Password: <input type="password" name="password" value="" /><br /><br />
<input type="submit" name="submit" value="Submit Form" />
</body>
</html>
我不明白为什么我会收到此错误。我一遍又一遍地筛选这些代码,但似乎看不出有什么问题。我在编写代码时非常陌生,所以如果它简单,我会感到惊讶,但我只是看不到它。