-
Notifications
You must be signed in to change notification settings - Fork 2
/
send_email.php
52 lines (34 loc) · 1.08 KB
/
send_email.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
<?php
$id = $_GET['id'];
//Connect DB
//Create query based on the ID passed from you table
//query : delete where Staff_id = $id
// on success delete : redirect the page to original page using header() method
$dbname = "incubation";
$conn = mysqli_connect("localhost", "root", "", $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM incubation WHERE id = $id";
// sql to delete a record
$result = mysqli_query($conn, $sql);
if ($result) {
$row = mysqli_fetch_array($result);
$to = $row['email'];
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){
header('Location: admin.php'); //If book.php is your main page where you list your all records
}else{
echo 'Error in mailing.';
};
mysqli_close($conn);
exit;
} else {
echo "Error deleting record";
}
?>