-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscribe.php
64 lines (55 loc) · 1.66 KB
/
subscribe.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
<?php
$page_title = 'Unsubscribe';
require_once './includes/navbar.php';
if ( ! isset( $_GET['email'] ) && ! isset( $_GET['otp'] )) {
echo 'Param Not Set';
header( 'Location: /404.php' );
}
$email = $_GET['email'];
$otp = $_GET['otp'];
if ( ! filter_var( $email, FILTER_VALIDATE_EMAIL ) && strlen( $otp ) !== 32 ) {
echo 'Invalid Params';
header( 'Location: /404.php' );
}
try {
$stmt = $con->prepare( 'SELECT email, otp FROM `subscribers` WHERE email = ? ' );
$stmt->bind_param( 's', $email );
$stmt->execute();
$stmt->bind_result( $db_email, $db_otp );
$stmt->fetch();
$stmt->close();
$otp_hash = md5( $db_otp );
} catch (\Throwable $th) {
echo $th->getMessage();
header( 'Location: /404.php' );
}
if ( $email !== $db_email || $otp !== $otp_hash ) {
echo 'Credentials Missmatch';
header( 'Location: /404.php' );
} else {
try {
$stmt = $con->prepare( 'UPDATE `subscribers` SET is_activated = 1 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 Subscribed</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 successfully subscribed<br /> Your first comic will reach to you shortly.
</h5>
</div>
</div>
<?php
}
require_once './includes/footer.php';