I get the following error. I checked the Stack Overflow post for situations like that but I couldn't figure it out,i really looked inside the code for around 30 minutes. I'd be really thankful for anyone who could help me with this error. I think my brackets are completely messed up... The error is :
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\photographer\includes\signup.inc.php on line 20
The signup.inc.php file code is :
<?php
if(isset($_POST['submit'])){
include_once 'dbh.inc.php';
$first = mysqli_real_escape_string($conn, $_POST['first']);
$last = mysqli_real_escape_string($conn, $_POST['last']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$uid = mysqli_real_escape_string($conn, $_POST['uid']);
$pwd = mysqli_real_escape_string($conn, $_POST['pwd']);
//error handler
//checking for empty fields
if(empty($first) || empty($last) || empty($email) || empty($uid) ||
empty($pwd) ) {
header("Location: register.php?register=empty");
exit();
} else {
//check if input characters are valid
if(!preg_match("/^[a-zA-Z]*$/", $first) || !preg_match("/^[a-zA-Z]*$/",
$last) {
header("Location: register.php?register=invalid");
exit();
} else {
//check if e-mail is valid
if (filter_var($email,FILTER_VALIDATE_EMAIL)) {
header("Location: register.php?register=email");
exit();
} else {
$sql = "SELECT * FROM users WHERE user_uid='$uid'";
$result=mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
header("Location: register.php?register=usertaken");
exit();
} else {
// hashing pass
$hashedPwd = password_hash($pwd, PASSWORD_DEFAULT);
//insert the user in db
$sql = "INSERT INTO users (user_first, user_last,
user_email, user_uid, user_pwd) VALUES ('$first', '$last', '$email',
'$uid', '$hashedPwd');";
mysqli_query($conn, $sql);
header ("Location: register.php?register=succes");
exit();
}
}
}
}
else {
header("Location: register.php");
exit();
}
?>
Thanks in advance for anyone that might answer my question!