-
Notifications
You must be signed in to change notification settings - Fork 0
/
unsubscribe.php
60 lines (51 loc) · 1.64 KB
/
unsubscribe.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
<?php
$page_title = 'Unsubscribe';
require_once './includes/navbar.php';
if ( ! isset( $_GET['email'] ) && ! isset( $_GET['id'] )) {
header( 'Location: /404.php' );
}
$email = $_GET['email'];
$id = $_GET['id'];
if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) && strlen( $id ) !== 32 ) {
header( 'Location: /404.php' );
}
try {
$stmt = $con->prepare( 'SELECT email, email_hash FROM `subscribers` WHERE email = ? AND email_hash = ? ' );
$stmt->bind_param( 'ss', $email, $id );
$stmt->execute();
$stmt->bind_result( $db_email, $email_hash );
$stmt->fetch();
$stmt->close();
} catch (\Throwable $th) {
echo $th->getMessage();
header( 'Location: /404.php' );
}
if ( $email !== $db_email || $email_hash !== $id ) {
header( 'Location: /404.php' );
} else {
try {
$stmt = $con->prepare( 'UPDATE `subscribers` SET is_activated = 0 WHERE email = ?' );
$stmt->bind_param( 's', $email );
$stmt->execute();
} catch (\Throwable $th) {
echo $th->getMessage();
header( 'Location: /404.php' );
}
?>
<div class="main-div center-div">
<div style="height:30vh">
<h1 style="color:white">Successfully Unsubscribed</h1>
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" />
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" />
</svg>
<h5 style="color:white;text-align:left">
Dear <?php echo $email; ?>
<br />
You have been successfully unsubscribed from Comic Newsletter.<br /> Head to <a href="index.php">here</a> to Subscribe again for newsletter.
</h5>
</div>
</div>
<?php
}
require_once './includes/footer.php';