-
Notifications
You must be signed in to change notification settings - Fork 0
/
validateNewsletterInput.php
41 lines (33 loc) · 1.01 KB
/
validateNewsletterInput.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
<?php
include "connection.php";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$mail = $_POST['mail'];
$sql = "SELECT isSubscribed FROM user WHERE email = '$mail'";
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) == 1)
{
$row = mysqli_fetch_assoc($result);
if($row['isSubscribed'] == 1)
{
echo "You are already subscribed!";
}
else
{
$sql = "UPDATE user SET isSubscribed = 1 WHERE email = '$mail'";
if(mysqli_query($conn, $sql))
{
echo "Thank you for subscribing! We will get back to you soon.";
}
else
{
echo "Something went wrong. Please try again later.";
}
}
}
else
{
echo "Please create an account to subscribe to our newsletter.";
}
}
?>