This script works, but it gives a warning if there is no match found:
if (...)
irrelevant...
elseif ($userId = mysql_result(
mysql_query("SELECT id FROM users WHERE mail = 'jhon@doe.com'")
, 0))
echo $userId;
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 4
Is this ‘good’ php? Or do I have to tackle this another way?
Goal of the script: If there is a user with that mail, give its ID
That’s pretty ugly, especially since you do not have any error handling etc.
Better create a function performing the check that returns the user id or NULL. Then you can use code like this: