-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
47 lines (35 loc) · 967 Bytes
/
Copy pathdelete.php
File metadata and controls
47 lines (35 loc) · 967 Bytes
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
<?php
session_start();
if (isset($_GET['DelLnk']))
{
header('location: index.php');
removeTask($_GET['DelLnk']);
}
if (isset($_POST['DelProfBtn']))
{
header('location: login.php');
removeUser($_SESSION['Id']);
}
function removeTask($rowNumber)
{
// $arrayStr = file('data.txt');
// unset($arrayStr[$rowNumber]);
// file_put_contents("data.txt", $arrayStr);
require_once 'connection.php';
$db = mysqli_connect($host, $user, $password, $database);
$query ="DELETE FROM `tasks` WHERE Id = " . $rowNumber . " AND UserId = " . $_SESSION['Id'];
$result = mysqli_query($db, $query);
while($row = mysqli_fetch_assoc($result))
{
$arrayStr[] = $row;
}
updateTask();
mysqli_close($db);
}
function removeUser($Id)
{
require_once 'connection.php';
$db = mysqli_connect($host, $user, $password, $database);
$query ="DELETE FROM `users` WHERE Id = " . $Id;
mysqli_query($db, $query);
}