谁能告诉我为什么 PHP 给我这个错误?:
Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\Task2PHP\final\registration.php on line 139
(错误是*中的错误,因为我没有输出所有代码)
我似乎找不到问题
代码:
<?php
if ($isLoggedin === false) {
include("form.php");
if (isset($_POST['Name'])) {
// DECLARE VARIABLES TO NULL
$Name = null; $Surname = null; $Username = null; $Email = null; $C_Email = null; $Password = null; $C_Password = null; $SecQ = null; $SecA = null;
// GET ELEMENTS FROM BROWSER POST.
if (isset($_POST['Name'])) {
$Name = $_POST['Name'];
}
if (isset($_POST['Surname'])) {
$Surname = $_POST['Surname'];
}
if (isset($_POST['Username'])) {
$Username = $_POST['Username'];
}
if (isset($_POST['Email'])) {
$Email = $_POST['Email'];
}
if (isset($_POST['C_Email'])) {
$C_Email = $_POST['C_Email'];
}
if (isset($_POST['password'])) {
$Password = $_POST['password'];
}
if (isset($_POST['c_password'])) {
$C_Password = $_POST['c_password'];
}
if (isset($_POST['SecQ'])) {
$SecQ = $_POST['SecQ'];
}
if (isset($_POST['SecA'])) {
$SecA = $_POST['SecA'];
}
// CONNECT TO MYSQL DB
$con = mysql_connect('localhost', 'storefileuser', 'storefileuser');
mysql_select_db ("storefile");
if (!$con) {
die('Could not connect: ' . mysql_error());
} else {
if ($Name == null || $Surname== null || $Password == null || $C_Password == null || $Email == null || $C_Email == null || $SecQ == null || $SecA == null ) {
echo "Missing details. Please enter all fields.";
} else {
$usernameexists = false;
$emailexists = false;
$result = mysql_query("SELECT * FROM users WHERE username = '$Username'");
if (mysql_num_rows($result) > 0) {
$usernameexists = true;
}
$result = mysql_query("SELECT * FROM users WHERE Email = '$Email'");
if (mysql_num_rows($result) > 0) {
$emailexists = true;
}
if (!$emailexists || !$usernameexists) {
// VALIDATE CONFIRMS
if ($Email == $C_Email && $Password == $C_Password) {
$encrypt_password=md5($Password);
$query = "INSERT INTO users (Username, Name,Surname, Password, Email, SecQ, SecA) VALUES ('".$Username."', '".$Name."', '".$Surname."', '".$encrypt_password."', '".$SecQ."', '".$SecA."', '".$Email."')";
echo "You have been successfully registered.";
}
} else {
echo "Error registering.";
} else {
echo "Username or email already entered in the database!";
}
}
}
}
} else {
echo '<h1> You are already registered/logged in!</h1>';
}
?>