This is my code:
$amountError = '';
$amountMin = 0.50; // Minimum amount
$amountMax = 100; // Maximum amount
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (empty($_POST['amount'])) {
$amountError = 'Empty amount';
}
if (!filter_var($_POST['amount'], FILTER_VALIDATE_FLOAT,
array("options" => array(
"min_range"=>$amountMin,
"max_range"=>$amountMax))) === false) {
header('Location: apmoketi.php');
exit; // Should I use it?
} else {
$amountError = 'Incorrect amount';
}
}
The problem is, if the amount is empty, I'm getting 'Incorrect amount', but not 'Empty amount' error. And if the amount is filled in but not between $amountMin
and $amountMax
then I got redirected to 'apmoketi.php' page, but don't get the 'Incorrect amount' error.
How do I fix that?