re:[PHP] login problem fixed!!
| From: | Andy B | Date: | Thu, 25 Mar 2004 10:43:54 +0000 |
| Subject: | re:[PHP] login problem fixed!! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181469@lists.php.net to get a copy of this message | ||
So, just for the sake of me getting this right, it would be better code if i
had the code like this:
<?
$UserExists=mysql_query("select * from users where
username='$_POST[username]' and pwd=md5($_POST[password])");
//since query is done see if the user exists
if($UserExists) {
ExistingUserCanDoSomething(); }
else {
YouCantDoAnythingIfYouDontExist(); }
?>
forgive the odd severely long redundant example names but... im sure that is
better than what i had before...
let me know if i got the right idea...
and $UserExists in this example is either true or false because "empty set"
in mysql isnt even a number it = NULL
echo $UserExists;//prints 0 if false and 1 if true
//at least in this instance of it (normally it would return total rows
matched)
at the point of logins i dont care about the # of rows it will alwas return
0 or 1 so true/false is best for me right now. when i create the user
generater then i will need to check for multiple usernames/passwords (2
users cant have the same pwd or id)...
anyways...off my box again