-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.php
More file actions
30 lines (24 loc) · 833 Bytes
/
delete.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: index.php');
if(!isset($_GET['id'])){
die('No id, go back to the <a href="index.php">Tenants Page</a>');
};
require_once('tenantDB.php');
if(!is_numeric($_GET['id']) || $_GET['id']<0){
die('Invalid, go back to the <a href="index.php">Hotels Page</a>');
}
$tenants=new tenantDB;
try{
$tenants->create();
$tenant=$tenants->pdo->query('SELECT first, last FROM tenant WHERE tenantID='.$_GET['id']);
$name=$tenant->fetch();
} catch (PDOException $e) {
throw new PDOException($e->getMessage(), (int)$e->getCode());
}
$first=$name['first'];
$last=$name['last'];
$tenants->delete($_GET['id']);
echo "$first $last".' has been successfully deleted, go back to the <a href="index.php">Tenants Page</a>'
?>