<?php
    include("config.php");
    session_start();
    if($_SERVER["REQUEST_METHOD"] == "POST") {
        $ID = mysqli_real_escape_string($db,$_POST['ID']);

        $sql = "SELECT * FROM tasks WHERE ID='$ID'";
        if($result = $db->query($sql)){
            if($result->num_rows > 0){
                while($row = $result->fetch_array()){
                    $sql_notif = "UPDATE tasks SET `Notif_Status`='read' WHERE `ID`= $ID";
                    if($db->query($sql_notif)){
                    }   
                    $_SESSION['notif_profile_picture'] = $row['Profile_Picture'];
                    $_SESSION['notif_username'] = $row['Username'];
                    $_SESSION['notif_id'] = $row['ID'];
                    $_SESSION['notif_file_name'] = $row['File_Link'];
                    $_SESSION['notif_code'] = $row['Code'];
                        echo '<form name="myForm" id="myForm" target="_parent" action="../tasks.php?ID='.$row['ID'].'" method="post">';
                        echo '  <input type="submit" value="Submit" style="visibility: hidden;">';
                        echo '</form>';
                        echo "</td>";
                    echo "</tr>";
                }
            // Free result set
            $result->free();
            }
        }
    } 


// Close connection
$db->close();
                            
?>

<script type="text/javascript">
    window.onload=function(){
        document.getElementById("myForm").submit();
    }
</script>