<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
$staffID = $_POST['staffID'];
date_default_timezone_set("Asia/Singapore");
$checkInTime = $_SERVER['REQUEST_TIME'];
$today = date('Y-m-d');
require_once('dbconnect.php');
$sqlcheck = "SELECT * FROM StaffAttendacne WHERE StaffID = '$staffID' AND Date ='$today'";
$sql = "INSERT INTO StaffAttendance (StaffID,Date,CheckInTime) VALUES ('$staffID','$today','$checkInTime')";
$result = mysqli_query($con,$sqlcheck);
$check = mysqli_fetch_array($result);
if (isset($check)){
echo "You have already checked in";
}else {
echo"$checkInTime";
mysqli_query($con,$sql);
}
how to write php insert check in time (insert time stamp) into SQL database. Time is when app launch . I have written this block of code but did not work
you are using if (isset($check)){
which will always be true because you ahve defined $check
just above it therefore your mysqli_query($con,$sql);
is not running.
You should instead use if(count($check) > 0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.