-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdelete-task.php
49 lines (38 loc) · 1.26 KB
/
delete-task.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
include('config/constants.php');
//Check task_id in URL
if(isset($_GET['task_id']))
{
//Delete the Task from Database
//Get the Task ID
$task_id = $_GET['task_id'];
//Connect Databaes
$conn = mysqli_connect(LOCALHOST, DB_USERNAME, DB_PASSWORD) or die(mysqli_error());
//SElect Database
$db_select = mysqli_select_db($conn, DB_NAME) or die(mysqli_error());
//SQL Query to DELETE TASK
$sql = "DELETE FROM tbl_tasks WHERE task_id=$task_id";
//Execute Query
$res = mysqli_query($conn, $sql);
//CHeck if the Query Executed Successfully or Not
if($res==true)
{
//Query Executed Successfully and TAsk Deleted
$_SESSION['delete'] = "Task Deleted Successfully.";
//redirect to Homepage
header('location:'.SITEURL);
}
else
{
//FAiled to Delete Task
$_SESSION['delete_fail'] = "Failed to Delete Task";
//Redirect to Home PAge
header('location:'.SITEURL);
}
}
else
{
//Redirect to Home
header('location:'.SITEURL);
}
?>