I’m working on a login page for a PHP database (xaamp) and this code is for the sign-up part. This code is meant to check if the database has an existing username. When there are no inputs in the database, the sign-up page works but once a submission is made no more can be made after that. I’m not too sure how to fix that. This is HTML, javascript and PHP.
if (uidExists($conn, $username) !== false) {
header("location: ../homepage.php?error=usernametaken");
exit();
}
function uidExists($conn, $username) {
$sql = "SELECT * FROM user_information WHERE UserUid = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("location: ../homepage.php?error=stmtfailed");
exit();
}
mysqli_stmt_bind_param($stmt, "s", $username);
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);
}