Jump to content

[SOLVED] Is there anything wrong with…


kmaid

Recommended Posts

Hi guys,

 

My login system has a database field called “LastActivity” which I use to clear out old accounts. At current when a user logs on i run the msql query

SELECT * FROM `Users` where `UserName` = ‘$UserName’ and `Password` = ‘Password’ LIMIT 1

and then I run an update query to set last activity to the current date time. 

UPDATE `users` Set `LastActivity` = NOW() where `UserName` = ‘$UserName’ and `Password` = ‘Password’ LIMIT 1

 

It occurred to me today if I could get away with using just update query and check the number of rows affected to see if they were found. In my mind it should work nicely however as it’s a login system I decided I should check ^^;

 

Kmaid

 

It looks very similar to what I have in my login script...

 

$query = "SELECT * FROM users WHERE username ='".$username."' AND active='1'";
//...password check comes later...//
$query1 = "UPDATE users SET logincount=logincount+1,lastlogin= now() WHERE id='$uid'";
//...after user and password are verified, update # of logins and activity...//

 

Once I check for the username, everything else uses the id field from the users table.

Well it worked perfectly right up until i realised that i needed to take their account status into account with the login script so i needed the userdata which isnt returned in an update :<! Oh well it was a nice idea teach me to optimise before its done lol!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.