<?php include("includes/config.php"); if(!isset($_POST['deleteAll']) ){ header("location: index.php"); } else { // when the delete form is submitted // create object $task1 = new Tasks(); // call the delete function $task1->deleteAll(); header("location: index.php"); } ?>