1
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 facilitate but I have never seen a registration page that worked that way.
Additional details:
- I’m using the codes correctly, for each of the
elsehas aifin the code. - In the database there is a table
usersand within the table hasusernameandemail The
stmtare 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'; } }
pq the two queries, one with only one
orwould not solve?– rray
as a matter of convenience for the user to know if the email or username are already in use or both(which in the case of
bind_paramof Fatal error). Nomysqli -> querythis could be done easily. If it is not possible I will have to usemysqli -> queryagain to check andbind_paramto enter the data in the database.– Lukaz11