I've been dabbling abit with a login script (PHP and MySQL), using various online tutorials. Today I became curious as to which way is the best to check if a username and password is valid. Every tutorial I've read so far checks the number of row returned, like this:
SELECT stuff FROM users WHERE username = input_username AND password = input_password
count the rows returned
if rows equal to one
login
else
display error message
I was just thinking if it's equally viable to use COUNT and check that value instead, like this:
SELECT COUNT(stuff) FROM users WHERE username = input_username AND password = input_password
if returned value equal to one
login
else
display error message
I've tried both and both work return the intended result. So is there any reason to choose one over the other?