kmaid Posted October 28, 2008 Share Posted October 28, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/130409-solved-is-there-anything-wrong-with%E2%80%A6/ Share on other sites More sharing options...
MadTechie Posted October 28, 2008 Share Posted October 28, 2008 looks okay to me (i assume ‘ and ’ are single quotes) Quote Link to comment https://forums.phpfreaks.com/topic/130409-solved-is-there-anything-wrong-with%E2%80%A6/#findComment-676490 Share on other sites More sharing options...
IndyTechNerd Posted October 28, 2008 Share Posted October 28, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/130409-solved-is-there-anything-wrong-with%E2%80%A6/#findComment-676529 Share on other sites More sharing options...
kmaid Posted October 28, 2008 Author Share Posted October 28, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/130409-solved-is-there-anything-wrong-with%E2%80%A6/#findComment-676589 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.