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());
}
}
?>