I have an "Empty Database" of users.
The first thing I want to do with my code if check if user id exist, before creating them an user ID.
I am getting following error: Trying to get property 'num_rows' of non-object
I have taken my query and submitted it on mysql and return nothing.
My HTML submit form:
<form action="index.php" method="post" autocomplete="off">
<input type="text" name="username" placeholder="Username" />
<input type="password" name="password" placeholder="Password" />
<input type="submit" value="Login" />
</form>
I am testing if user name exist.
$query=("SELECT count(*) FROM users WHERE user_name = ?,[$username]");
$result = mysqli_query($conn, $query);
if ($result)
{
$result = mysqli_fetch_all($result,MYSQLI_ASSOC);
return $result;
} else {
return mysqli_affected_rows($conn);
}
After the test, it will submit my query to create user account.