I am working on an attendance project in Java Swing. Log in should be only once a day.
My project contains of login page which has a database from which user names and passwords are given, I just want to make sure that login (attendance updated for an employee) takes place only once a day.
How to check whether the date changed?
Does it really matter if someone logs in more than once a day? Actually, your requirement has a spoofing problem. Suppose that a coworker stole my password, and he used it to log in as me. Then I come in, and I now cannot log in. It's better to allow users to log in whenever they want, and to show a message "You last logged in at 8:45 AM EDT on 3 June 2013".
If you need this exact requirement, store the last login date in the database as a SQL DATE type, which does not have time-of-day. Have the login code look like
This really isn't Swing-specific, or even Java-specific. You'll want to look at how your database can compute message hashes, and how you can apply salt to the passwords. You'll need to decide the salt source.
If you're using a Java Calendar, you can also just store last login, then compare to current one:
Create a database table for storing the log data of
login
data and have a columnsuserid
,date
andlogin
information. And you can program iflogin
value is0
then the person didn't login otherwise he logged in. If you are clever enough,login
column is not needed even. Now, if a user tries to log in, check if the record exits in the table against that user for that day.That's all