-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.php
53 lines (44 loc) · 2.07 KB
/
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
<?php
include './config.php';
// Upload Payment Details to the Database
if (isset($_POST['payment'])) {
$teamID = $_POST['teamID'];
$paymentDate = $_POST['payment-date'];
$transactionId = $_POST['transaction-id'];
$paymentScreenshot = $_FILES['payment-screenshot'];
$paymentScreenshotName = $paymentScreenshot['name'];
$paymentScreenshotTmpName = $paymentScreenshot['tmp_name'];
$paymentScreenshotExt = explode('.', $paymentScreenshotName);
$paymentScreenshotActualExt = strtolower(end($paymentScreenshotExt));
$allowed = array('jpg', 'jpeg', 'png', 'pdf');
// Check if the user has already registered
$sql = "SELECT * FROM teams WHERE T_ID = '$teamID'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// Check if the user has already uploaded the payment details
$sql = "SELECT * FROM payment WHERE T_ID='$teamID'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
header("Location: ./paymentScreenshot.php?error=AreadyUploaded");
exit();
}
// Check if folder available
if (!file_exists('./assets/payments')) {
mkdir('./assets/payments', 0777, true);
}
$paymentScreenshotNameNew = $teamID . "." . $paymentScreenshotActualExt;
$paymentScreenshotDestination = './assets/payments/' . $paymentScreenshotNameNew;
$sql = "INSERT INTO payment ( T_ID, PAYMENT_DATE, TRANSACTION_ID, SCREENSHOT) VALUES ('$teamID', '$paymentDate', '$transactionId', '$paymentScreenshotDestination')";
$result = mysqli_query($conn, $sql);
if ($result) {
move_uploaded_file($paymentScreenshotTmpName, $paymentScreenshotDestination);
header("Location: ./paymentScreenshot.php?success=paymentSuccess");
} else {
header("Location: ./paymentScreenshot.php?error=uploaderror");
}
} else {
header("Location: ./paymentScreenshot.php?error=invalidTeamID");
}
} else {
header("Location: ./paymentScreenshot.php?error=InvalidRequest");
}