-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_delete.php
33 lines (28 loc) · 889 Bytes
/
user_delete.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
<?php
//cek session
session_start();
require_once 'config/config.php';
if (empty($_SESSION['loggedin'])) {
header("Location: ./");
die();
} elseif ($_SESSION['level'] === 'Kasir') {
header("Location: ./home.php");
} else {
if (!isset($_GET['id_user'])) {
header('Location: user.php');
}
$id_user = $_GET['id_user'];
$sql = "SELECT * FROM tb_user WHERE id_user=$id_user";
$query = mysqli_query($db, $sql);
$user= mysqli_fetch_assoc($query);
if (mysqli_num_rows($query) < 1){
header("Location: user.php");
} else {
$sql = "DELETE FROM tb_user WHERE id_user=$id_user";
$query = mysqli_query($db, $sql);
if ($query) {
$_SESSION['success'] = 'Data user berhasil dihapus.';
header('Location: user.php');
}
}
}