0

i want to take the attendence of the students from database...if they once punch-in then i want to disable it upto clicking the punch-out button if browser 've been closed ! so how can i get it can pls anyone help me :) :))

Edited by ratanji

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by leviathan185
1

I think you may need to do some research on the Javascript onunload & onbeforeunload events. Maybe have them call an ajax function.

here is an example of the usage.

1

First you save the user_id, action_type (IN or OUT) and current_time of user on table.
Then check last action type of that user.
If last action_type is IN , show punch out button, else show punch in button.

0

thanq Varghese can u suggest me the query or code for that after creation of the tables ?

1

It would look something like this

<?php
    // assuming you have connected to the database and set up the table
    // and your user is already logged in and jsut needs to "punch in"

    $sql = 'SELECT `action_type` FROM `users` WHERE `username` = \'{$username}\' LIMIT 1';
    $result = mysql_query($sql);
    $row = mysql_fetch_assoc($result);
    if ( $row['action_type'] == 'IN' ) {
        // display code to puch out
    } else {
        // display code to punch in
    }
?>

I haven't tested this but it should work with some modifictaion with your existing code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.