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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.