I see you check for sql injection of the loginname:
$loginName = mysql_real_escape_string($loginName);
$loginName = mysql_real_escape_string($loginName);
Do you filter bad content for the submitted password?
edit: nowNow that I look at it, you are sending the POSTed login name straight to the SQL, aren't you?
thisThis:
new user($db,$_POST['username']);
shouldShould be this:
new user($db,$loginName);
If I'm reading this correctly - you need to sanitize the password also!
This is generally very important. YouYou are also using mysqlMySQL functions to sanitize sql liteSQLite data. That's probablyprobably okay, but I wouldn't bet the farm on it!