- Edited
Hi all not only am I new to the forum (my name is Alex and I am 16 years) I am trying to learn PHP, I feel I am mastering HTML and CSS (not 100% there still finding this I didn't know) and felt PHP is the natural progression in becoming an around web developer.
For the last two days, I have been staring at the code below and getting nowhere. I am getting a
PHP Parse error: syntax error, unexpected 'else' (T_ELSE) in Standard input code on line 8
I cannot find where I am missing '{' or '}'.
I know you must get loads joining to ask the same questions. I would be truly grateful if someone could have a look over the code and point out where I am going wrong. Thanks once again for your help.
<?php
function emptyInputRegister($name, $surname, $userdob, $userUid, $houseNameNumber, $address, $postcode, $email, $email2, $Pwd, $Pwd2){
$result;
if (empty($name) || empty($surname) || empty($userdob) || empty($userUid) || empty($houseNameNumber) || empty($address) || empty($postcode) || (empty($email) || empty($email2) || empty($Pwd) || empty($Pwd2)) {
$result = true;
} else {
$result = false;
}
return $result;
}
function invalidUserUid($userUid){
$result;
if (!preg_match("/^[a-zA-Z0-9]*$/", $userUid)) {
$result = true;
}else{
$result = false
} return $result
}
function invalidEmail($email){
$result;
if (!filter_var($email, FILLTER_VALIDATE_EMAIL)) {
$result = true;
}else{
$result = false
} return $result
}
function emailMatch($email, $email2){
$result;
if ($email !== $email2) {
$result = true;
}else{
$result = false
} return $result
}
function passwordMatch($Pwd, $Pwd2){
$result;
if ($pwd !== $pwd2) {
$result = true;
}else{
$result = false
} return $result
}
function userUidExists($conn, $userUid, $email){
$sql = "SELECT * FORM user WHERE userUid = ? OR userEmail = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../login/login.php?error=stmtfailed");
exit();
}
mysqli_stmt_bind_param($stmt, "ss" $userUid, $email);
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($userUid, $name, $middleName, $surname, $Email, $pwd, $userdob, $House, $Address, $address2, $city, $postcode) {
$sql = "INSERT INTO users (userUid, userName, userMiddelName, userSurname, userEmail, userpwd, userdob, userHouse, userAddress, useraddress2, userCity, userPostcoder) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../login/login.php?error=stmtfailed");
exit();
}
$hashedpwd = password_hash($pwd, PASSWORD_DEFAULT);
mysqli_stmt_bind_param($stmt, "ssssssssssss" $userUid, $name, $middleName, $surname, $Email, $hashedpwd, $userdob, $House, $Address, $address2, $city, $postcode);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
header("location: ../login/login.php?error=none");
exit();