-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathdelete-list.php
53 lines (39 loc) · 1.48 KB
/
delete-list.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
50
51
52
53
<?php
//Include constants.php
include('config/constants.php');
//echo "Delete List Page";
//Check whether the list_id is assigned or not
if(isset($_GET['list_id']))
{
//Delete the List from database
//Get the list_id value from URL or Get Method
$list_id = $_GET['list_id'];
//Connect the DAtabase
$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());
//Write the Query to DELETE List from DAtabase
$sql = "DELETE FROM tbl_lists WHERE list_id=$list_id";
//Execute The Query
$res = mysqli_query($conn, $sql);
//Check whether the query executed successfully or not
if($res==true)
{
//Query Executed Successfully which means list is deleted successfully
$_SESSION['delete'] = "List Deleted Successfully";
//Redirect to Manage List Page
header('location:'.SITEURL.'manage-list.php');
}
else
{
//Failed to Delete List
$_SESSION['delete_fail'] = "Failed to Delete List.";
header('location:'.SITEURL.'manage-list.php');
}
}
else
{
//Redirect to Manage List Page
header('location:'.SITEURL.'manage-list.php');
}
?>