How can you run a search for whether or not a row exists based on an identifier. For example: I need to create a fairly simple system that allows a user to log in and then change options (i.e. update table set XX where user='user'😉. But- how do I find out if that user ID exists in the table first. The process has to work like this: User enters Username PHP checks if Username exists in Database if yes- check password, then allow in if no- reject user.
How do you check if a thing exists in a database table?
Thanks!
um, if i have your question right, all you need to do is this:
"select ID from table where user = 'username'";
if you return an ID, the row is there. if you don't, the row is not
Ok... That's a start: now, how do you make it so it will come back and say "I can't find the username! You can't get in!" So it's not so much a "select" as it is a "does it exist".
Any ideas? Thanks!
just use something like this right after the query:
if($ID == 0) die("I can't find blah blah");