Hello all I am having problem with my attendance management system.
The problem is when ever i log in as admin it does not show a log in time but when ever i log in as a user it is howing time in.

And secondly the time in and tim out is wrong. The time is not according to my system time or PST i.e according to Pakistan standard time which is +5 GMT

Thank you all in advance and srry for bad english :P

Regards
Usman

Also attached the images.

Member Avatar

Like your last thread, you do not include any details with regard to your code. This is getting a bit frustrating. Please read the php sticky: http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question

Do not expect answers if you cannot include all the relevant information, such as the all-important CODE.

The problem is when ever i log in as admin it does not show a log in time but when ever i log in as a user it is howing time in

How do you expect members to be able to help you with this?

For Timezones, search the PHP manual for 'timezone'

I am sorry I forgot to paste the code :P

This code is on the web page i meand home page. Little bit confused as well.
Here is the code:

<?php
$result = @$_GET["result"];

$date = date('Y-m-d');
$day = date('l');
$min = date('i');
$hour = date('h');
$second = date('s');

$min = $min - 5;
if($min<0){ $hour=$hour-1; $min=$min+60; $second=$second+60;}
$time = $hour.":".$min.":".$second;
$settime = $time;
$settime1 = date('h:i:s');
?>
    <?php
                 $result = @$_GET["result"];

                $date = date('Y-m-d');
                $day = date('l');
                $min = date('i');
                $hour = date('h');
                $second = date('s');

                $min = $min - 5;
                if($min<0){ $hour=$hour-1; $min=$min+60;}
                $time = $hour.":".$min.":".$second;
                $settime = $time;
                $settime1 = date('h:i:s');

                $query = "select * from presence where uid=".$uid." and date='".$date."'";
                $recordset = mysql_query($query);
                while(@$record = mysql_fetch_array($recordset)){
                $count = 1;
                //echo "<td>Today you timed in at:- ",$record["timein"],"</td></tr><br></table>";
                //$lasttimeout = $record["timeout"];
                }
                if(@$count!=1) 
                {
                $query2 = "insert into presence(timein, timeout, date, uid, pday) 
                values('$settime', '$settime1', '$date', $uid, '$day')";
                $af = mysql_query($query2);
                //echo "<td>Today you timed in at:- ",$settime,"</td></tr><br></table>";
                $lasttimeout = date('h:i:s');
                }

                //echo "<table><tr><td>Today you last timed out at:- ",$lasttimeout," 
                //</td></tr></table>";
                 $array1 = array();
                    $array2 = array();
                    $array3 = array();
                    $array4 = array();
                    $userid = array();
                    $great = 0; 
                 function calculate($timein, $timeout) {
                    @$timespentin = split(":",$timein,3);
                    @$timespentout = split(":",$timeout,3);
                    //print_r($timespentin);
                    //print_r($timespentout);
                    $t1 = $timespentin[0]*60 + $timespentin[1];
                    $t2 = $timespentout[0]*60 + $timespentout[1];
                    $timespent = round(($t2 - $t1)/60,2);
                    //echo $timespent;
                    return $timespent;
                    }

                    $sday = 1;
                    $today = date ("d");
                    $month = date("m");
                    $year = date("Y");
                    $date1 = $year."-".$month."-".$sday;
                    $date2 = $year."-".$month."-".$today;

                    $recordset5 = mysql_query("select * from nwdays where nwdate between '".$date1."' and '".$date2."' and uid=0  and holidaytype=2 order by nwdate");
                    $ndays = 0;
                    while($record5 = mysql_fetch_array($recordset5)) {
                        $ndays = $ndays + 1;
                    }
                    $towday = $today - $ndays;

                    $recordset15 = mysql_query("select * from nwdays where nwdate between '".$date1."' and '".$date2."' and uid=".$uid." and holidaytype=0 order by nwdate");
                    $undays = 0;
                    while(@$record15 = mysql_fetch_array($recordset15)) {
                        $undays = $undays + 1;
                    }
                    //$towhours = $towday * 8;
                    $towday = $towday - $undays ;

                $query = "select * from users where uid =".$uid;
                $recordset = mysql_query($query);
                while(@$record = mysql_fetch_array($recordset)) {
                $whours = $record["uwhours"];
                $towhours = $towday * $whours;
                $totaltime = 0;
                $query1 = "select * from presence where uid =".$uid." and date between '".$date1."' and '".$date2."' order by date";
                $recordset1 = mysql_query($query1);
                while($record1 = mysql_fetch_array($recordset1)) {
                $timein = $record1["timein"];
                $timeout = $record1["timeout"];

                $daytime = calculate($timein, $timeout);
                $totaltime = $totaltime + $daytime;
                }
                $ttimehm = explode(".",$totaltime,2);
                $hours = $ttimehm[0];
                @$ttimehm = split(".",$totaltime,2);
                $minutes = round ($ttimehm[1]*60,0);
                //echo $hours,"---",$minutes;
                if ($minutes >59) {$minutes = $minutes%60;}
                $div = $minutes/10;
                if($div<1) {$minutes = "0".$minutes;}

                $totaltime = $hours.":".$minutes;
                }

                $month = date("m");
                    $year = date("Y");

                 $startday = 1;
                 $endday = date("d");

                    $date1 = $year."-".$month."-".$startday;
                    $date2 = $year."-".$month."-".$endday;

                    $recordset9 = mysql_query("select * from configuration where setname='relaxedhours'");
                    while($record9 = mysql_fetch_array($recordset9)) {
                    $relaxedhours = $record9["setvalue"];
                    }

                    $recordset4 = mysql_query("select * from nwdays where nwdate 
                    between '".$date1."' and '".$date2."' and uid=0 and holidaytype=2 order by nwdate");

                    $days = 0;
                    while($record4 = mysql_fetch_array($recordset4)) {
                        $days = $days + 1;
                    }
                    $wdays1 = $endday - $days;
                    //$whours = $wdays *8;

                $recordset = mysql_query("select * from users");
                while($record = mysql_fetch_array($recordset)) {

                $recordset15 = mysql_query("select * from nwdays where nwdate between '".$date1."' and '".$date2."' and uid=".$record["uid"]." and holidaytype=0 order by nwdate");
                    $undays = 0;
                    while($record15 = mysql_fetch_array($recordset15)) {
                        $undays = $undays + 1;
                    }
                    $wdays = $wdays1 - $undays;

                $whours1 = $record["uwhours"];
                $whours = $wdays * $whours1;
                $totaltime = 0;
                $query1 = "select * from presence where uid =".$record["uid"]." and date between '".$date1."' and '".$date2."' order by date";
                $recordset1 = mysql_query($query1);
                while($record1 = mysql_fetch_array($recordset1)) {
                $timein = $record1["timein"];
                $timeout = $record1["timeout"];
                $totaltime = $totaltime + calculate($timein, $timeout);
                //$timespent = split(":",$timein,2);
                //print_r($timespent);
                }
                $ttimehm = explode(".",$totaltime,2);
                $hours = $ttimehm[0];
                @$ttimehm = split(".",$totaltime,2);
                $minutes = round ($ttimehm[1]*60,0);
                if ($minutes >59) {$minutes = $minutes%60;}
                $div = $minutes/10;
                if($div<1) {$minutes = "0".$minutes;}
                $totaltime = $hours.":".$minutes;
                $userid["$great"] = $record["uid"];     
                    $array1["$great"] = $record["ulogin"];      
                    $array2["$great"] = $whours;
                    $array3["$great"] = $totaltime;
                    //$array4["$great"] = $minutes;
                    $great++;   
                }

                $greatest = 0;
                for ( $i=0; $i < $great; $i++ )
                {
                     $greatest = $array3[$i];
                     @$greatest = split(":",$greatest,"2");
                     $array3[$i] = ($greatest[0] * 60) + $greatest[1];
                }        

                for ( $i=0; $i < $great; $i++)
                {
                     for ( $j=$i+1; $j < $great; $j++ )
                     {                         
                           if ( $array3[$j] > $array3[$i])
                           {                    
                                $temp1 = $array1[$j];
                                $temp2 = $array2[$j];
                                $temp3 = $array3[$j];
                                $temp4 = $userid[$j];                   

                                $array1[$j] = $array1[$i];
                                $array2[$j] = $array2[$i];
                                $array3[$j] = $array3[$i];
                                $userid[$j] = $userid[$i];

                                $array1[$i] = $temp1;
                                $array2[$i] = $temp2;
                                $array3[$i] = $temp3;
                                $userid[$i] = $temp4;                   
                           }        
                     }
                }

                for ( $i=0; $i < $great; $i++ )
                {
                      $totaltime = $array3[$i];
                      $totalhours = intval($totaltime/60);     
                      $totalminutes = $totaltime%60;
                      if($totalminutes<10) {$totalminutes = "0".$totalminutes;}
                      $array3[$i] = $totalhours.":".$totalminutes;

                }
                for ( $i=0; $i < $great; $i++ )
                {            
                      if(($array3[$i]+$relaxedhours)< $array2[$i]) 
                      {
                          if ( $uid == $userid["$i"] )
                               echo"<tr bgcolor='skyblue'><td><div align='left'>",$array1["$i"],"</td>
                                        <td align='center'>",$array2[$i],"</td><td align='center'><font color='red'>",$array3[$i],"</font></td></tr>"; 
                          else        
                               echo"<tr><td><div align='left'>",$array1["$i"],"</td>
                                        <td align='center'>",$array2[$i],"</td><td align='center'><font color='red'>",$array3[$i],"</font></td></tr>";
                      }

                      else
                      {
                          if ( $uid == $userid["$i"] )
                               echo"<tr bgcolor='skyblue'><td><div align='left'>",$array1["$i"],"</td>
                                       <td align='center'>",$array2[$i],"</td><td align='center'>",$array3[$i],"</td></tr>";
                          else
                              echo"<tr><td><div align='left'>",$array1["$i"],"</td>
                                       <td align='center'>",$array2[$i],"</td><td align='center'>",$array3[$i],"</td></tr>";
                       }
                }
            ?>

------------------------------------------------------------------------------------------------------

do you have a role based system in your attendance application?

<?php $query = "select * from presence where uid=".$uid." and date='".$date."'";
$recordset = mysql_query($query);
while($record = mysql_fetch_array($recordset))

                        {$count = 1;
                        //echo "<td>Your Time In :==: ",$record["timein"],"</td></tr><br></table>";
                        echo "<center><table><tr><td>Your Time In : ",$record["timein"],"</td></tr></table></center>";
                        $lasttimeout = $record["timeout"];
                        }

                        echo "<center><table><tr><td>Your Time Out : ",$lasttimeout,"</td></tr></table></center>";
                    ?>