After lots of trying, I need help. After a click event, i perform checking on data exist in my database and use jscript to pop a confirmation box.
How to get it works as I click cancel, its not showing any value I set on confirm.php?
Confirm with OK and Cancel
jscript code:
if($row_count2 > 0)
{
    if ($row2["Status"] == "REJECTED")
    {
    <script type="text/javascript">
        if (!confirm('Lot No has been REJECTED before.. Double confirm to add the Lot No!!')) {
        var option = "NO";
        $.ajax({
            type: "POST", 
            url: "confirm.php",
            data: "value="+option,
            success: function (data) {
                alert(data);
            }         
        });
    }
    </script>
    }
}
$ll = $_SESSION['Confirm'];
echo "<script type='text/javascript'>alert('$ll');</script>";
if ($row_count2 < 1 || ($_SESSION['Confirm'] = "YES"))
{
    //my insert query is here...
}
And this is inside confirm.php:
<?php    
    session_start();
    
    $xx = $_REQUEST["value"];
    $_SESSION['Confirm'] = $xx;
    echo "<script type='text/javascript'>alert('$xx');</script>";
?>
I'm expecting to get $_SESSION['Confirm'] value as NO
By default $_SESSION['Confirm'] value is YES
alert(data) shows that $xx is NO but when I put alert for $_SESSION['Confirm'] value on if condition
before my insert query $_SESSION['Confirm'] value still remain YES

 
     
    