hi,
i need to create an attendance register that logs a user, the time into office, the time out of office (at end of day) and of course the date itself.
I initially wanted to combine this with the login script but that would not work because a user may log in and log out of his webpages several times a day . i only need a record of the time user gets in and leaves office.
i'm sure there's an easier way somewhere but having gone spare trying to figure it out, i just created a file attendance.php as a link on a users index.php page
But I find that the logout info doesnt get saved ( if attend ==0) in the same script given below
Could some one guide me pl ? Thanks and M/C.
Swati
<?php
$id = $HTTP_POST_VARS["id"];
$t1 = $HTTP_POST_VARS["t1"];
$t2 = $HTTP_POST_VARS["t2"];
$message = $HTTP_POST_VARS["message"];
?>
<?php
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
if ( $attend == 1 )
{
$sql1 = "INSERT INTO `Attendance` (id, ip1, date, timein) VALUES ('$id', '$message', '$t1', '$t2')" ;
echo $sql1;
$result1 = mysql_query($sql1)
or die (mysql_error());
echo "
<p>Thank you for signing in "; echo $id; echo " !</p> ";
$sql2="select max(AID) from `Attendance`";
$result2 = mysql_query($sql2)
or die ("Unable to get results");
$myrow2 = mysql_fetch_row($result2);
$aid = $myrow2[0];
}
// Upto here the code works - problems from below
if ( $attend == 0 )
{
$result3 = mysql_query ("UPDATE `Attendance` SET ip2='$message',timeout='$t1' WHERE AID=$aid AND id = '$id' " );
echo "
<p>Thank you for logging out ! Good Day and see you back tomorrow !</p>";
}
?>