forked from backupbrain/double-opt-in-registration-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunsubscribe.php
55 lines (37 loc) · 844 Bytes
/
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
<?
// unsubscribe.php
require_once('classes/EmailRegistration.class.php');
// let's define some outcomes for this page
define('STATUS_DEFAULT', 0);
define('STATUS_SUCCESS', 1);
define('STATUS_ERROR', 2);
$status = STATUS_DEFAULT;
$email = $_GET['email'];
$EmailRegistration = new EmailRegistration();
try {
$EmailRegistration->fetchByEmail($email);
$EmailRegistration->unsubscribe();
$status = STATUS_SUCCESS;
} catch(Exception $e) {
$status = STATUS_ERROR;
}
switch($status) {
case STATUS_SUCCESS:
?>
<h1>Success</h1>
<p>Your email address, <?= $EmailRegistration->email; ?> has been unsubscribed.</p>
<?
break;
case STATUS_ERROR:
?>
<h1>Error</h1>
<p>There was a problem unsubscribing your email address.</p>
<?
break;
default:
?>
<h1>Hello</h1>
<p>You have come to this page in error.</p>
<?
}
?>