<pre>
<?php
function emptyInputSignup($name, $surname, $contact_Number, $email_Address, $organisation, $position, $username, $password, $repeat_Password){
$result = "";
if(empty($name) || empty($surname) || empty($contact_Number) || empty($email_Address) || empty($organisation) || empty($position) || empty($password) || empty($repeat_Password) || empty($surname)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function invalidUsername($username){
$result = "";
$pattern = "/^[a-zA-Z0-9]*$/";
if(!preg_match($pattern, $username)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function invalidEmail($email_Address){
$result = "";
if(!filter_var($email_Address, FILTER_VALIDATE_EMAIL)){
$result = true;
}
else{
$result = false;
}
return $result;
}
function pswMatch($password, $repeat_Password) {
$result = "";
if ($password !== $repeat_Password) {
$result = true;
}
else {
$result = false;
}
return $result;
}
function UserNameExists($conn, $username, $email_Address){
$sql = "SELECT * FROM user WHERE Username = ? OR Email = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../pages/Users/Registration_Form.php?error=SqlStatementFailed");
exit();
}
mysqli_stmt_bind_param($stmt, "ss", $username, $email_Address);
mysqli_stmt_execute($stmt);
$resultData = mysqli_stmt_get_result($stmt);
if($row = mysqli_fetch_assoc($resultData)){
return $row;
}
else{
$result = false;
return $result;
}
mysqli_stmt_close($stmt);
}
function createUser($conn, $name, $surname, $contact_Number, $email_Address, $organisation, $position, $username, $password, $repeat_Password){
$sql = "INSERT INTO user (Name, Surname, Contact_Number, Email, Organization, Position, Username, Password) VALUES (?,?,?,?,?,?,?,?);";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
header("Location: ../pages/Users/Registration_Form.php?error=SqlStatementFailed");
exit();
}
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "ssssssss", $name, $surname, $contact_Number, $email_Address, $organisation, $position, $username, $hashedPassword);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("Location: ../pages/Users/Registration_Form.php?error=noErrors");
exit();
}
What I have tried:
The function pswMatch states the following:
'}' expected.
I have gone through the code to double check all brackets. I have even rewritten the function but I still get the same error message.