In this code when I want to update the status from Pending to Accepted that time If statement not working. In database I keep Pending by default. Problem is that when I'm going to update the status the STATUS will update but the code inside the If condition can't work. please help me out from this problem. Thanks in advance.
<?php
include("connect.php");//conection
if(isset($_REQUEST['leave_id']))
{
$id=$_REQUEST['leave_id'];
}
else
{
$id=NULL;
}
$result = mysqli_query($con,"SELECT TAKEN_LEAVES,BALANCE_LEAVE,STATUS
FROM xxxemi_person_leave_t
WHERE leave_id= $id");
$res = mysqli_fetch_array($result);
if (!$result)
{
die("Error: Data not found..");
}
$taken_leave = $res['TAKEN_LEAVES'];
$balance_leave = $res['BALANCE_LEAVE'];
$status = $res['STATUS'];
if(isset($_POST['save']))
{
if ($status=='ACCEPTED')
{
$status = $_POST['USTATUS'];
$updated_balance_leave = $_POST['UBALANCE_LEAVE'];
$updated_balance_leave = $balance_leave - $taken_leave;
mysqli_query($con,"UPDATE xxxemi_person_leave_t
SET STATUS ='$status', BALANCE_LEAVE ='$updated_balance_leave'
WHERE leave_id = '$id' ");
echo "<script>alert('Your Record Updated');</script>";
}
else
{
$status = $_POST['USTATUS'];
mysqli_query($con,"UPDATE xxxemi_person_leave_t
SET STATUS ='$status'
WHERE leave_id = '$id' ");
echo "<script>alert('Your Record Updated');</script>";
}
}
mysqli_close($con);
?>
/**************PHP CODE *******/
<form method="post">
<td><input type="hidden" name="id" value=<?php echo $_GET['leave_id'];?>>
<input type="hidden" name="UBALANCE_LEAVE" value="<?php echo $updated_balance_leave;?>">
<input type="checkbox" name="USTATUS" value="ACCEPTED" />
<img src="images/Approved.png" />
<input type="checkbox" name="USTATUS" value="REJECTED" />
<img src="images/Rejected.png" /></td>
<input type="submit" name="save" value="Update">
</form>
/************* HTML CODE**********/