Need your help with my Code.
The page is for approving the "leave application"
For example, the employee applied for "Sick Leave"
and It is approved it will deduct 1 from the sl_credit
which is from the user_info table on my database and will also update the remarks, remarkable, and status to the tblleaves table
.
I am getting an error message "error updating table"
On my code, I just tried the "Approved" to test if it is working.
I hope someone could help me with this. I'm very new to programming and would really appreciate your help.
Thanks in advance.
<?php
$uid = $_GET['ref'];
$leavetype = $_GET['leavetype'];
$adminremark = $_POST['adminremark'];
$status = $_POST['status'];
$adminremarkdate = $_POST['adminremarkdate'];
$date = date("Y-m-d H:i:s");
include '../db_config/connection.php';
if ($leavetype == "Sick Leave" || $status == "Approved") {
$sql = "UPDATE tblleaves, user_info SET adminremark='$adminremark', status='$status', adminremarkdate = '$date', user_info.sl_credit=user_info.sl_credit-1, WHERE id='$uid'";
}elseif ($leavetype == "Vacation Leave" || $status == "Approved") {
$sql = "UPDATE tblleaves, user_info SET adminremark='$adminremark', status='$status', adminremarkdate = '$date', user_info.vl_credit=user_info.vl_credit-1, WHERE id='$uid'";
}
if ($conn->query($sql) === TRUE) {
header("location:leave-details.php?ref=$uid");
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>