Delete Button Code
As you can see I'm trying to redirect the user index.php after deleting data. How can I do that?
Here is the action form:
<form action="scripts.php" method="POST">
      <input type="hidden" name="delete_id" value="<?php echo $row['id']; ?>">
      <input type="hidden" name="del_new_name" value="<?php echo $row['new_name']; ?>">
      <button type="submit" name="delete_new_name" class="btn btn-danger">Delete</button>
</form>
Post Method Code
Here is the post method code on scripts.php file:
//scripts.php File:
        
        if (isset($_POST['delete_new_name'])) {
            $id = $_POST['delete_id'];
            $new_name = $_POST['del_new_name'];
        
        
            $query = "DELETE FROM uploaded_files WHERE id='$id' ";
            $query_run = mysqli_query($conn, $query);
        
            if ($query_run) {
                unlink("uploads/" . $new_name);
                $_SESSION['status'] = "Data Deleted Successfully";
                header('location: index');
                
                
            } else {
                $_SESSION['status'] = "Data Not Deleted";
                header('location: index.php');
                
            }
        }
Session Status
Here is the Session Status code on the index.php
<?php
      if (isset($_SESSION['status']) && $_SESSION != '') {
            ?>
              <div class="alert alert-warning alert-dismissible fade show" role="alert">
                <strong> Hey! </strong> <?php echo $_SESSION['status']; ?>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                  <span aria-hidden="true">×</span>
                </button>
              </div>
            <?php
              unset($_SESSION['status']);
            }
            ?>
It goes scripts.php file and deletes the data from the folder and database, after deleting it, it doesn't redirect index.php. I think I'm missing something plz help me out
 
    