-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscribe.php
executable file
·89 lines (73 loc) · 2.65 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
//print_r($_POST);die;
ini_set('display_errors',true);
require "components.php" ;
$fields = array("email","category","mon","tue","wed","thu","fri","sat","sun");
if(!empty($_POST) ){
if(empty($_POST["email"])){
echo "no email supplied";
exit();
}
if(empty($_POST["category"]) or $_POST["category"]=="None"){
echo "no category supplied";
exit();
}
$db = new mysqli("email.c9ssouqvesbm.us-west-2.rds.amazonaws.com","root","email123","Email Subscription");
if($db->connect_error){
echo $db->connect_error."<br>"."connection not successfull";
}
$stmt = $db->prepare("INSERT INTO users (email,category, mon,tue,wed,thu,fri,sat,sun) VALUES(?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE mon =?, tue=?, wed=?,thu=?,fri=?,sat=?,sun=?,category=?");
if(!$stmt) //if there is an error, then it will be shown!.
{ // show error
echo $db->error;
exit();
} else {
//echo 10; die;
}
foreach($fields as $field){
if ($_POST[$field]=="none" ){
$_POST[$field]=null;
}
}
$stmt->bind_param('ssiiiiiiiiiiiiiis',$_POST["email"],$_POST["category"],$_POST["mon"],$_POST["tue"],$_POST["wed"],$_POST["thu"],$_POST["fri"],$_POST["sat"],$_POST["sun"],$_POST["mon"],$_POST["tue"],$_POST["wed"],$_POST["thu"],$_POST["fri"],$_POST["sat"],$_POST["sun"],$_POST["category"]);
$response = $stmt->execute();
// check user if verified
$user = $db->prepare("SELECT status from users where email= ?");
$user->bind_param("s",$_POST["email"]);
$response = $user->execute();
$result = $user->get_result();
$myrow = $result->fetch_assoc();
if($response){
if($myrow["status"]!="verified"){
$body=generate_email_html($_POST["email"]);
$status=send_questions($_POST["email"],$body,"Subliminal Prime Verification");
if($status){
echo 1;
exit();
}
else{
echo 0;
exit();
}
}
else{
$body=generate_email_preference($_POST["email"]);
$status=send_questions($_POST["email"],$body,"Preference update");
if($status){
echo 1;
exit();
}
else{
echo 0;
exit();
}
}
}
else{
echo 0;
}
}
else{
echo "no input found";
}
?>