-
Notifications
You must be signed in to change notification settings - Fork 0
/
sql_Payment.php
44 lines (38 loc) · 1.62 KB
/
sql_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
<?php
include 'connectdb.php';
session_start();
if(isset($_POST['submitPayment'])){
$reg_id = $_POST['payment_Id'];
$method = $_POST['payment_method'];
$totalPayable = (int)$_POST['paymentTotalPayable'];
$payment = (int)$_POST['payment_amount'];
$remaining = $totalPayable-$payment;
$remarks = $_POST['payment_remarks'];
$date = date('y-m-d h:i:s');
// echo ($reg_id ." ID");
if($totalPayable > 0){
$query = "INSERT INTO `payment`(`reg_id`, `payment_amount`, `payment_type`, `remarks`, `date_issued`) VALUES ('$reg_id','$payment','$method','$remarks','$date')";
$result = mysqli_query($conn, $query);
echo $query;
if($result){
echo '<script>alert("Record Saved Successfully");</script>';
$query2 = "UPDATE `registration` SET remainingPayment='$remaining' WHERE reg_id='$reg_id'";
$result2 = mysqli_query($conn, $query2);
if($result){
echo '<script>alert("Record Updated Successfully");</script>';
header("Location: home.php");
}
else{
echo '<script>alert("Failed to Update Record");</script>';
}
}
else{
echo '<script>alert("Failed to Save Record");</script>';
}
}
else{
echo '<script>alert("Record Not Updated");</script>';
header("Location: home.php");
}
}
?>