resse1991 Posted August 27, 2014 Share Posted August 27, 2014 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 https://forums.phpfreaks.com/topic/290666-employee-time-card-using-php/ Share on other sites More sharing options...
IanA Posted August 27, 2014 Share Posted August 27, 2014 In what way is the date/time incorrect? $date = date('Y-m-d'); $time = date('H:i:s'); Try the above, that will give you the date and time of the current timestamp. Link to comment https://forums.phpfreaks.com/topic/290666-employee-time-card-using-php/#findComment-1489036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.