Jump to content

employee time card using php


resse1991

Recommended Posts

Hey guys, I am new to php and I have a project to do that includes creating a payroll system.What i am trying to get done is a clock in and clock out time card using php.This is what I have so far but when I run it, the date and time is incorrect can someone please help me :

 

here's what i have so far:

<?php
include 'include/dbconnection.php';
 
 $filled = true;
 
$EmpNum = $_REQUEST["empno"];
 
if ($EmpNum == "") {
    $filled = false;
 
}
 
if ($filled == false) {
    print "Must enter a valid employee number to log in. Click <a href = 'timecard.html'>HERE</a> to return to the login screen";
} else {
    $timestamp = $_SERVER['REQUEST_TIME'];
    $date = date('Y-m-d', $timestamp);
    $time =(date('H-i-s', $timestamp));
    print $timestamp . "<br>";
 
    print $EmpNum . " has just logged ";
 
    if (($SubmitButton = $_REQUEST["submit"]) == "ClockIn") {
 
 
 
 
        print "in on " . $date . " at " . $time;
        $query = "INSERT INTO timestamp(empno, Date, TimeIn, TimeOut) VALUES (".$EmpNum.",'".$date."','','".date('H:i:s')."')";
         print $query;
         $result=mysql_query ($query,$link) or die ("invalid query".mysql_error());
 
       
    } else if (($SubmittButton = $_REQUEST["submit"]) == "ClockOut") {
        print "out on " . $date . " at " . $time;
        $query = sprintf("INSERT INTO timestamp(empno, Date, TimeIn, TimeOut) VALUES (".$EmpNum.",'".$date."','',".$time.")");
        print $query;
         $result=mysql_query ($query,$link) or die ("invalid query".mysql_error());
}
       
    }
 
?>
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.