-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathajax-subscribe.php
More file actions
33 lines (25 loc) · 888 Bytes
/
ajax-subscribe.php
File metadata and controls
33 lines (25 loc) · 888 Bytes
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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-db-connection.php");
include($_SERVER['DOCUMENT_ROOT'] . "/includes/inc-functions.php");
if (isset($_POST['newsletter-email'])) {
$email = $_POST['newsletter-email'];
if (strlen($email) > 150) {
stderr("Your <strong>email</strong> address cannot be longer than 150 characters.");
}
$dupe = DB::getInstance()->selectOneByField('newsletters', 'newsletter_email', $email);
if (!empty($dupe)) {
stderr("Your <strong>email</strong> address is already on the subscribed list!");
} else {
$i = DB::getInstance()->insert(
'newsletters',
[
'newsletter_email' => $email,
'newsletter_date' => date('Y-m-d H:i:s')
]
);
stdmsg("Your <strong>email</strong> address <strong>{$email}</strong> has been successfully subscribed.");
}
}
}
?>