Skip to content

Instantly share code, notes, and snippets.

@AriffAzmi
Created September 8, 2015 00:04
Show Gist options
  • Save AriffAzmi/727a48ee2e7d5b13e036 to your computer and use it in GitHub Desktop.
Save AriffAzmi/727a48ee2e7d5b13e036 to your computer and use it in GitHub Desktop.
<?php
include 'config.php';
$class_id = $mysqli->real_escape_string($_GET['id']);
$send_mail = "SELECT * FROM book WHERE id = '" . $class_id . "'";
$r_mail = $mysqli->query($send_mail);
while ($row = $r_mail->fetch_assoc()) {
$book_by = $row['username'];
$class = $row['book_room'];
$date = $row['d_book'];
$stime = $row['start_time'];
$etime = $row['end_time'];
}
$message = 'Good day' . ' ' . $book_by . '.' . ' ' .
'Your class booking have been deleted by system administration. Please contact the system administration for more details' . ' ' .
'Here your booking details:' . ' ' . ' ' .
'Class:' . ' ' . $class . ',' . ' ' .
'Date:' . ' ' . $date . ',' . ' ' .
'Start time:' . ' ' . $stime . ',' . ' ' .
'End time:' . ' ' . $etime;
$mail_to_user = "SELECT email FROM user WHERE username = '" . $book_by . "'";
$r_mail_user = $mysqli->query($mail_to_user);
$f = $r_mail_user->fetch_object();
$user_mail = $f->email;
mail($user_mail, 'Notification From CFGS class boking system', $message, "From: [email protected]");
// Proceed to delete
$Q = "DELETE FROM book WHERE id= '" . $class_id . "'";
$R = $mysqli->query($Q);
if ($R) {
echo '<script>' . 'alert("Booking deleted");' . '</script>';
echo '<script>' . 'window.location.href="home.php";' . '</script>';
}
else {
echo '<script>' . 'alert("Something error");' . '</script>';
echo '<script>' . 'window.location.href="home.php";' . '</script>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment