-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete.php
66 lines (55 loc) · 1.88 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<link rel="stylesheet" type="text/css" href="ex.css">
</head>
<body>
<?php
//Rewritten by Fabio Pinto as per specifications
//Silencing output
ob_start();
include('config.php');
ob_end_clean();
include('menu.php');
//Pear Mail has been installed and will be used to notify us when a user is deleted
require_once 'Mail.php';
//Simple Mail server Options for the local server
$options = array();
$options['host'] = 'localhost';
//Creating the mailer object
$mailer = Mail::factory('smtp', $options);
//Defining the mail message headers
$headers = array();
$headers['From'] = '[email protected]';
$headers['To'] = '[email protected], [email protected]';
$headers['Subject'] = 'ICT3612 Task12: Record Deleted!';
//Defining the recipent list
$recipients = '[email protected], [email protected]';
if(isset($_GET['id'])){
$id=$_GET['id'];
//Modifiying query, not using named or question mark parameter by the variable directly
$query = 'DELETE FROM addd WHERE id= '.$id;
$query2 = 'SELECT name FROM addd WHERE id= '.$id;
//Preparing statements
$statement = $db->prepare($query);
$statement2 = $db->prepare($query2);
//executing statement 2 first before the record is deleted....
$statement2->execute();
$statement->execute();
$rows = $statement2->fetchAll();
foreach ($rows as $row) {
$name = $row['name'];
}
if($query){
header('location:index.php');
//define mail bodyhere as this is if block confirms deletion of the record
$body = 'Record with name : '.$name.' has been deleted';
//Send mail from this block as thisblock confirms deletion of the record
$mailer->send($recipients, $headers, $body);
}
}
?>
</body>
</html>
<a href="index.php">Back...<a>
</br><iframe src="delete.txt" height="400" width="1200">
<p>Your browser does not support iframes.</p></iframe>