-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_em.php
43 lines (34 loc) · 1.01 KB
/
delete_em.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
34
35
36
37
38
39
40
41
42
43
<?php
require_once 'db_em.php';
$id2 = $_GET['id2'];
$servername = "localhost:3306";
$username = "root";
$password = "root";
$databaseName = "database".$id2;
$conn = new mysqli($servername,$username,$password,$databaseName);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
function RemoveAll ( $path ) {
foreach ( new DirectoryIterator($path) as $item ):
if ( $item->isFile() ) unlink($item->getRealPath());
if ( !$item->isDot() && $item->isDir() ) RemoveAll($item->getRealPath());
endforeach;
rmdir($path);
}
if (file_exists('worker faces'.$id2.'/'.$_GET['name'])){
RemoveAll('worker faces'.$id2.'/'.$_GET['name']);
}
$id='';
if(!empty($_GET['id'])){
$id = $_GET['id'];
}
if(empty(id)){
throw new Exception('ID is blank');
}
$querry="DELETE FROM images WHERE id='".$id."'";
mysqli_query($conn,$querry);
$conn->close();
header("Location: /add_an_employee.php?id=".$id2);
die;
?>