I built a register and login system on my website. Now I asked myself a question that I cannot answer. I have three inputs on my registration page:
I would now like to have two inputs on my login page instead. The first should be for password and the second for email OR username. I now wonder how it is possible to do this with the MySQL database?
I am still very new to PHP. I hope someone can answer, I haven't found anything on Stack Overflow.
If you have a two fields called "username" and "email" in your database, and you want to check if the user exists based on the user having potentially entered either one of these values, then you could write a query something like this:
SELECT *
FROM users
WHERE username = ? OR email = ?
which would return any row where the parameter value matches the content of either the username or the email column.
(Adjust for your exact table and column names, obviously.)
Prepare your query accordingly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.