-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscribe.php
143 lines (125 loc) · 4.06 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
session_start();
include_once "includes/db.php";
$output = "";
if(isset($_SESSION['CarUserEmail']))
{
$user_email = user_input($_SESSION['CarUserEmail']);
$user_account_info = fetch_user_info_profile($conn, $user_email);
if(isset($_GET['plan']))
{
$plan = user_input($_GET['plan']);
$sql = "SELECT * FROM bookpackage WHERE email='$user_email' AND status='activated';";
$sql_result = mysqli_query($conn, $sql);
$entries = mysqli_num_rows($sql_result);
if($entries > 0)
{
$output = "
<div style='margin-top:4rem;text-align:center;'>
<h3>You are already subscribed to plan.</h3>
<a href='myaccount.php'>Go Back</a>
</div>
";
}
else
{
$user_model = $user_account_info['model'];
$user_brand = $user_account_info['brand'];
$vehicleType = "";
$charges = 0;
$sql = "SELECT * FROM model WHERE model='$user_model' AND brand='$user_brand';";
$sql_result = mysqli_query($conn, $sql);
if($sql_result)
{
while($row = mysqli_fetch_assoc($sql_result))
{
$vehicleType = $row['vehicleType'];
}
}
if(($vehicleType == 'hatchback' || $vehicleType == 'sedan') && $plan == 'Basic')
{
$charges = 699;
}
else if(($vehicleType == 'hatchback' || $vehicleType == 'sedan') && $plan == 'Standard')
{
$charges = 999;
}
else if(($vehicleType == 'hatchback' || $vehicleType == 'sedan') && $plan == 'Premium')
{
$charges = 1199;
}
else if($vehicleType == 'suv' && $plan == 'Basic')
{
$charges = 899;
}
else if($vehicleType == 'suv' && $plan == 'Standard')
{
$charges = 1199;
}
else if($vehicleType == 'suv' && $plan == 'Premium')
{
$charges = 1399;
}
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$query = "INSERT INTO bookpackage (email, plan, planvisit, plancharge, datemade, dateexpire, txn_id, status) VALUES ('$user_email', '$plan', 0, '$charges', '$now', DATE_ADD(CURDATE(), INTERVAL 1 MONTH), '$txnid', 'deactivated');";
$result = mysqli_query($conn, $query);
if($result)
{
header('location: formprocess2.php?email='.$user_email.'&txn_id='.$txnid);
exit();
}
else
{
$output = "<div style='margin-top:4rem;text-align:center;'>
Something went wrong
</div>";
}
}
}
else if (isset($_GET['action']))
{
$action = user_input($_GET['action']);
$query = "DELETE FROM bookpackage WHERE email='$user_email' AND status='activated';";
$result = mysqli_query($conn, $query);
if($result)
{
header('location: myaccount.php');
exit();
}
}
else
{
header('location: index.php');
exit();
}
}
else
{
header('location: index.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Pack subscribe</title>
<link rel="shortcut icon" href="images/icon.png" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<div id="bodyWrapper">
<?php include_once "includes/header.php"; ?>
<?php echo "$output"; ?>
</div>
<?php include_once "includes/footer.php"; ?>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.6/ScrollMagic.min.js"></script>
<script src="js/script.js"></script>
</body>
</html>