On my records page, I want to check the names of users and emails separately but at the same time.
I could leave the message like this: Username or email already exists
to make it easier but I've never seen a registration page that works that way.
Additional details:
- I am using the codes correctly, for each of the
else
has aif
in the code. - In the database there is the
users
table and inside the table hasusername
andemail
-
stmt
are working separately.$username = $_POST['username']; $email = $_POST['email']; $id = ''; else{ $stmt = $mysqli -> prepare('SELECT id FROM users WHERE username = ?'); $stmt -> bind_param("s", $username); $stmt -> execute(); $stmt -> bind_result($id); $stmt -> fetch(); if($id > 0){ $user_error = 'Username already exists'; } } else{ $stmt = $mysqli -> prepare('SELECT id FROM users WHERE email = ?'); $stmt -> bind_param("s", $email); $stmt -> execute(); $stmt -> bind_result($id); $stmt -> fetch(); if($id > 0){ $email_error = 'Email already exists'; } }