forked from Kajanan02/music-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
artist-payment.php
143 lines (118 loc) · 7.57 KB
/
artist-payment.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();
require_once './scripts/paypal-config.php';
require_once "./classes/db-connector.php";
use classes\DBConnector;
if (isset($_POST["signup"])) {
if (empty($_POST["name"]) || empty($_POST["email"]) || empty($_POST["city"]) || empty($_POST["username"]) || empty($_POST["password"])) {
header("Location: ./artist-register.php?error=1"); //empty fields
} elseif ($_POST["country"] == "") {
header("Location: ./artist-register.php?error=2"); //choose a country
} elseif (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
header("Location: ./artist-register.php?error=3"); //invalid email
} else {
$temp_con = DBConnector::getConnection();
$query_temp1 = "SELECT artist_name FROM artist WHERE artist_name = ?";
$pstmt_temp1 = $temp_con->prepare($query_temp1);
$pstmt_temp1->bindValue(1, $_POST["name"]);
$pstmt_temp1->execute();
if ($pstmt_temp1->rowCount() != 0) {
header("Location: ./artist-register.php?error=4"); //artist exists
}
else {
$query_temp2 = "SELECT username FROM artist WHERE username = ?";
$pstmt_temp2 = $temp_con->prepare($query_temp2);
$pstmt_temp2->bindValue(1, $_POST["username"]);
$pstmt_temp2->execute();
if ($pstmt_temp2->rowCount() != 0) {
header("Location: ./artist-register.php?error=5"); //username exists
}
else{
$_SESSION["name"] = $_POST["name"];
$_SESSION["email"] = $_POST["email"];
$_SESSION["city"] = $_POST["city"];
$_SESSION["country"] = $_POST["country"];
$_SESSION["username"] = $_POST["username"];
$_SESSION["password"] = $_POST["password"];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Payment</title>
<link rel="icon" type="image/png" href="./assets/logos/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap 5.0.2 -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js" integrity="sha384-fbbOQedDUMZZ5KreZpsbe1LCZPVmfTnH7ois6mU1QK+m14rQ1l2bGBq41eYeM/fS" crossorigin="anonymous"></script>
<link rel="stylesheet" href="./css/premium.css">
</head>
<body>
<nav class="navbar nav-dashboard bg-dark shadow">
<div class="container-fluid">
<span class="navbar-brand mb-0 h1 px-5 text-white"> <a href="./index.php"> <img src="assets/logo-transparent.png" alt="Logo" width="200px" /></a></span>
</div>
</nav>
<div class=" bg-dark">
<div class="row m-0 artist-login-container">
<div class="col-md-6 d-flex align-items-md-center mt-5 artist-login-image">
<img src="assets/register-artist.png" width="100%" style="z-index: 1">
<img src="assets/play-btn-5.png" width="100%" class="bg-play">
</div>
<div class="col-md-6 d-flex align-items-center justify-content-center">
<div class="mb-3">
<label for="plan" class="form-label text-white h4 mt-4">Choose your plan</label>
<?php
$query = "SELECT plan_id, plan_name, price FROM subscription WHERE plan_type=?";
try {
$con = DBConnector::getConnection();
$pstmt = $con->prepare($query);
$pstmt->bindValue(1, "Artist");
$pstmt->execute();
$result = $pstmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $r) {
?>
<div class="product-box mt-5 mb-5">
<div class="row mt-4 d-flex justify-content-center align-items-center">
<h5 class="h5 text-light"><?php echo $r["plan_name"]; ?></h5>
</div>
<div class="row d-flex justify-content-center align-items-center">
<h4 class="h4 text-light"><?php echo "USD " . $r["price"]; ?></h4>
</div>
<form class="mx-5 my-5 px-5" method="POST" action="<?php echo PAYPAL_URL; ?>">
<!-- Paypal Sandbox Business ID -->
<input type="hidden" name="business" value="<?php echo PAYPAL_ID; ?>">
<!-- Default Paypal "Buy Now" Button -->
<input type="hidden" name="cmd" value="_xclick">
<!-- Sending purchase data to Paypal API -->
<input type="hidden" name="item_name" value="<?php echo $r['plan_name']; ?>">
<input type="hidden" name="item_number" value="<?php echo $r['plan_id'];
$_SESSION["plan_id"] = $r['plan_id']; ?>">
<input type="hidden" name="amount" value="<?php echo $r['price']; ?>">
<input type="hidden" name="currency_code" value="<?php echo PAYPAL_CURRENCY; ?>">
<!-- Specifying Return, Cancel Payment and Notify URL of the site -->
<input type="hidden" name="return" value="<?php echo PAYPAL_RETURN_URL; ?>">
<input type="hidden" name="cancel_return" value="<?php echo PAYPAL_CANCEL_URL; ?>">
<input type="hidden" name="notify_url" value="<?php echo PAYPAL_NOTIFY_URL; ?>">
<input type="submit" name="signup" class="btn btn-primary fw-medium px-5 py-2 mt-4 btn-go" value="Choose Plan" />
</form>
</div>
<?php
}
} catch (PDOException $e) {
echo $e->getMessage();
}
?>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
}
}
?>