-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete_user.php
More file actions
41 lines (33 loc) · 1.14 KB
/
delete_user.php
File metadata and controls
41 lines (33 loc) · 1.14 KB
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
<?php
session_start();
// Σύνδεση με τη βάση δεδομένων χρησιμοποιώντας τον profile χρήστη
$host = "localhost";
$dbname = "student4198partB";
$username = "profileUSER";
$password = "Testing1001@";
$conn = new mysqli($host, $username, $password, $dbname);
// Έλεγχος σύνδεσης
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Έλεγχος αν ο χρήστης είναι Tutor
if (!isset($_SESSION['rolos']) || $_SESSION['rolos'] !== 'Tutor') {
echo "Μη εξουσιοδοτημένη πρόσβαση.";
exit();
}
// Έλεγχος αν υπάρχει το ID του χρήστη
if (!isset($_GET['id'])) {
echo "Μη έγκυρη αίτηση.";
exit();
}
$id = intval($_GET['id']);
// Διαγραφή του χρήστη
$stmt = $conn->prepare("DELETE FROM Xristes WHERE id = ?");
$stmt->bind_param("i", $id);
if ($stmt->execute()) {
header("Location: users.php");
exit();
} else {
echo "Υπήρξε πρόβλημα κατά τη διαγραφή του χρήστη.";
}
?>