我知道这已经发布了大约一万次,但是我已经检查了又一遍,甚至重写了整个文档,但是看来我无法修复。
所以请不要介意它已经发布过了。
问题所在:
我正在尝试编写一个PHP / HTML登录脚本,“ signup.php”具有表单数据,然后将它们传输到数据库和错误处理程序“ signup.inc.php”中。
无论何时输入表格,浏览器都会出现以下错误:
Parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\loginsystem\includes\signup.inc.php on line 64
这是signup.inc.php中的代码
<?php
if (isset($_POST['signup-submit'])) {
require 'dbh.inc.php';
$Username = $_POST['uidUsers'];
$Email = $_POST['emailUsers'];
$password = $_POST['pwdUsers'];
$passwordrepeat = $_POST['pwd-repeat'];
$vorname = $_POST['vornameUsers'];
$nachname = $_POST['nameUsers'];
$strasse = $_POST['streetUsers'];
$rufnummer = $_POST['phoneUsers'];
$hausnummer = $_POST['streetnoUsers'];
$plz = $_POST['plzUsers'];
$ort = $_POST['ortUsers'];
if (empty($Username)
|| empty($Email)
|| empty($password)
|| empty($passwordrepeat)
|| empty($vorname)
|| empty($nachname)
|| empty($strasse)
|| empty($rufnummer)
|| empty($hausnummer)
|| empty($plz)
|| empty($ort))
{
header("Location: ../signup.php?error=emptyfields&uidUsers=".$Username."&mail=".$Email);
exit();
} elseif (!filter_var($Email, FILTER_VALIDATE_EMAIL) && !preg_match("/^[a-zA-Z0-9]*$/",$Username)) {
header("Location: ../signup.php?error=invalidmailuid");
exit();
} elseif (!filter_var($Email, FILTER_VALIDATE_EMAIL)) {
header("Location: ../signup.php?error=invalidmail&uidUsers=".$Username);
exit();
} elseif (!preg_match("/^[a-zA-Z0-9]*$/",$Username)) {
header("Location: ../signup.php?error=invaliduid&mail=".$Email);
exit();
} elseif ($password !== $passwordrepeat) {
header("Location: ../signup.php?error=passwordcheck&uidUsers=".$Username."&mail=".$Email);
exit();
} else {
$sql = "SELECT uidUsers FROM users WHERE uidUsers=?";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
}
} else {
mysqli_stmt_bind_param($stmt, "s", $Username);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$resultcheck = mysqli_stmt_num_rows($stmt);
if ($resultcheck > 0) {
header("Location: ../signup.php?error=usertaken&mail=".$Email);
exit();
}
} else {
$sql = "INSERT INTO users (uidUsers, nameUsers, vornameUsers, pwdUsers, emailUsers, phoneUsers, streetUsers, streetnoUsers, plzUsers, ortUsers) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../signup.php?error=sqlerror");
exit();
}
} else {
$hashedPwd = password_hash($password, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "ssssssssss", $Username, $nachname, $vorname, $hashedPwd, $Email, $rufnummer, $strasse, $hausnummer, $plz, $ort);
mysqli_stmt_execute($stmt);
header("Location: ../signup.php?signup=success");
exit();
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
}
else {
header("Location: ../signup.php");
exit();
}
如果您有任何疑问或我的解释不正确,请问我
感谢您的关注和帮助