-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathadd_payment.php
60 lines (42 loc) · 1.59 KB
/
add_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
<?php
require('db.php');
$errors = array();
if (isset($_REQUEST['payment'])) {
$pay_id = mysqli_real_escape_string($conn, $_REQUEST['id']);
$amount = mysqli_real_escape_string($conn, $_REQUEST['amount']);
$gym_id = mysqli_real_escape_string($conn, $_REQUEST['gym_id']);
$user_check_query = "SELECT * FROM payment WHERE pay_id='$pay_id' LIMIT 1";
$result = mysqli_query($conn, $user_check_query);
$user = mysqli_fetch_assoc($result);
if ($user) {
if ($user['pay_id'] === $pay_id) {
array_push($errors, "<div class='alert alert-warning'><b>ID already exists</b></div>");
}
}
if (count($errors) == 0) {
$query = "INSERT INTO payment (pay_id,amount,gym_id)
VALUES('$pay_id','$amount','$gym_id')";
$sql=mysqli_query($conn, $query);
if ($sql) {
$msg="<div class='alert alert-success'><b>Payment area added successfully</b></div>";
}else{
$msg="<div class='alert alert-warning'><b>Payment area not added</b></div>";
}
}
}
?>
<div class="container">
<form class="mt-3 form-group" method="post" action="">
<h3>ADD PAYMENT AREA</h3>
<?php include('errors.php');
echo @$msg;
?>
<label class="mt-3">PAYMENT AREA ID</label>
<input type="text" name="id" class="form-control">
<label class="mt-3">AMOUNT</label>
<input type="text" name="amount" class="form-control">
<label class="mt-3">GYM ID</label>
<input type="text" name="gym_id" class="form-control">
<button class="btn btn-dark mt-3" type="submit" name="payment">ADD</button>
</form>
</div>