I have been trying to run a piece of PHP script for a number of user fields and I am continuing to get the parse error: unexpected 'else' (T_ELSE) on line 29 - the second else statement
I have checked that there is no semi colon after the if statement and all of the indenting appears to line up so I am not sure what is wrong. Could someone please assist. Thank you
<?php
if (issset($_POST['submit'])) {
require 'dbh.inc.php';
$firstname = $_POST['First name'];
$lastname = $_POST['Last name'];
$email = $_POST['Email'];
$number = $_POST['Phone number'];
$address = $_POST['Address'];
$pass = $_POST['Password'];
if (empty($firstname) or empty($lastname) or empty($email) or empty($number) or empty ($address) or empty($pass)) {
header("Location: ../html-1column.html?error=emptyfields&firstname=".$firstname." &email=".$email."");
exit();
}
else {
$sql="SELECT Email FROM users WHERE Email=?";
$stmt=mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../html-1column.html?error=sqlerror");
exit();
}
}
else {
mysqli_stmt_bind_param($stmt, "s", $email);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$resultcheck = mysqli_stmt_num_rows($stmt);
if ($resultcheck > 0){
header("Location: ../html-1column.html?error=usertaken");
exit();
}
else {
$sql="INSERT INTO users (First name, Last name, Email, Phone number, Address, Password) VALUES (?, ?, ?, ?, ?, ?)";
$stmt=mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: ../html-1column.html?error=sqlerror");
exit();
}
else {
$hashedpwd = password_hash($pass, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "ssssss", $firstname, $lastname, $email, $number, $address, $hashedpwd);
mysqli_stmt_execute($stmt);
header("Location: ../html-1column.html?signup=success");
exit();
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($conn);
} #open 10
else {
header("Location: ../html-1column.html");
exit();
}
?>