Hello I am trying to implement after they pay it checks how much they paid and inputs different variables in sql database with if methods.
The problem: The problem is all the if methods return to this first option(inserts paid=1, and 30days) not sure what the problem is, is my if method broken?what's wrong please explain! thanks!
if(number_format($amount, 2) == 8.00)
{
$mysqli = new mysqli(******);
$stmt = $mysqli->prepare("UPDATE `as_users` SET paid='1', reg_date=CURRENT_TIMESTAMP, end_date=DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL 30 DAY) WHERE username = ?");
$stmt->bind_param('s', $username);
$stmt->execute();
} elseif (number_format($amount, 2) == 10.00)
{
$mysqli = new mysqli(******);
$stmt = $mysqli->prepare("UPDATE `as_users` SET paid='2', reg_date=CURRENT_TIMESTAMP, end_date=DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL 30 DAY) WHERE username = ?");
$stmt->bind_param('s', $username);
$stmt->execute();
} elseif (number_format($amount, 2) == 100.00)
{
$mysqli = new mysqli(******);
$stmt = $mysqli->prepare("UPDATE `as_users` SET paid='2', reg_date=CURRENT_TIMESTAMP, end_date=DATE_ADD(CURRENT_TIMESTAMP(), INTERVAL 365 DAY) WHERE username = ?");
$stmt->bind_param('s', $username);
$stmt->execute();
}
Edit: I tried with $amount and also tried using the names of the array from dropdown menu I have
array("Basic Package-Monthly", "8.00", "Month", "1", "0", "0"),
array("Premium Package-Monthly", "10.00", "Month", "1", "0", "0"),
array("Premium Package-Annually", "100.00", "Year", "1", "0", "0"),
$mysqli = new mysqli(******);once, above theifstatement.number_format($amount, 2). If you put the result of that in a variable, you can just reference that variable in yourifstatements. It has the added bonus of putting the numeric value in one place so that you can check it.