-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminDelete.php
More file actions
30 lines (24 loc) · 833 Bytes
/
adminDelete.php
File metadata and controls
30 lines (24 loc) · 833 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
<?php
session_name('signIn');
session_start();
if(!isset($_SESSION['uid'])) header('LOCATION:signIn.php');
if($_SESSION['uid'] != 'admin') header('Location: index.php');
if(!isset($_GET['id'])){
die('No id, go back to the <a href="admin.php">Admin Page</a>');
};
require_once('userAccountsDB.php');
if(!is_string($_GET['id'])){
die('Invalid, go back to the <a href="admin.php">Admin Page</a>');
}
$users=new userAccount;
try{
$users->create();
$user=$users->pdo->query('SELECT email FROM useraccounts WHERE email="'.$_GET['id'].'"');
$email=$user->fetch();
} catch (PDOException $e) {
throw new PDOException($e->getMessage(), (int)$e->getCode());
}
$id=$email['email'];
$users->delete($id);
echo "$id".' has been successfully deleted, go back to the <a href="admin.php">Users Page</a>'
?>