Hello,

I'm creating a very simple time attendance management system.
Just a quick one where you can login just your code and it will store to mysql by reference of time.

My question is.
Currently I only have one table which is "LOGIN" only....
since this is a time attendance database.. I would love to have "LOGOUT"
by simple entering the code again...

but with a same database system, page and all....

So is it possible to create a time limit on a php, let say if the people entering code at less than 8 30 am it will directly go to LOGIN database ...
more than 08 30 am it will directly go to LATE database ...
more than 6 00 pm it will directlty go to LOGOUT database ...

thanks in advance .. :)

To change databases through an external input is something that reveals that there is a serious problem with the logic of your databases structure. You could do it for example taking the time and from that decide what the arguments of a PDO would be, but it is not a great idea. Just create one other table saying when you are logout for example and make the logon and logout a row to the first table. This is just an idea there are many moreā€¦ but stick that should be logic and structured.

Thanks... I'm thinking of different behavior now..

What if...

Each of one have different code... just a code.. no need a username or whatsoever..

let say member no.1 code abc123

When he enter the code abc123.. it means login.... he enter abc123 for the second time.. thats means logout... So, basically there's comparison here..

How i can do that ??

You need to have two distinct processes. One to log in and another to log out.

With the approach you have suggested, what if someone forgets to enter the code for a second time to logout?

With regard to your database structure, I would suggest a user table, and then an attendance / timecard table.

In the timecard table, I would suggest the following fields:
id - auto increment field
user_id - foreign key to user table
date - date field when record was created
sign_in - time field for user sign in
sign_out - time field for user sign out

I don't thing you wouldn't need to store whether a user was late or not in the table, as this could be ascertained using a query. E.g.:

$sql = "SELECT u.* 
    FROM users u
    INNER JOIN timecard t ON (u.id = t.user_id)
    WHERE t.sign_in > '08:30:00'
    GROUP BY u.user_id";

Great idea..

I'll give a try later..

Thanks blocblue

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.