Skip to content

Commit

Permalink
Fix calculation of total amount in add-member.php
Browse files Browse the repository at this point in the history
  • Loading branch information
HashJProgramming committed Feb 9, 2024
1 parent 876d644 commit d61d76c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions functions/add-member.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
include_once 'connection.php';

$fullname = $_POST['fullname'];
$fullname = $_POST['fullname'];
$sex = $_POST['sex'];
$phone = $_POST['phone'];
$address = $_POST['address'];
Expand All @@ -10,6 +10,14 @@
$birthdate = $_POST['birthdate'];
$amount = $_POST['amount'];

if ($type == 'Regular'){
$total = 300;
} elseif ($type == 'Premium'){
$total = 500;
} else {
$total = 800;
}

$sql = "SELECT * FROM members WHERE fullname = :fullname OR phone = :phone";
$stmt = $db->prepare($sql);
$stmt->bindParam(':fullname', $fullname);
Expand All @@ -25,7 +33,7 @@
$change = $amount - $total;

if ($change < 0) {
header('Location: ../rentals.php?type=error&message=Amount is not enough');
header('Location: ../members.php?type=error&message=Amount is not enough');
exit;
}

Expand Down
4 changes: 2 additions & 2 deletions functions/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

$id = $_POST['id'];
$type = $_POST['type'];
if ($type == 'REGULAR'){
if ($type == 'Regular'){
$total = 300;
} elseif ($type == 'PREMIUM'){
} elseif ($type == 'Premium'){
$total = 500;
} else {
$total = 800;
Expand Down

0 comments on commit d61d76c

Please sign in to comment.