I have got problem with this simple if statement:
$type = $_GET['type'];
if ($type !== 1 || $type !== 2) {
header('Location: payment.php');
exit;
}
Only type 1 and 2 are allowed, but...
Last example is OK, but I don't know why it redirects too in first and second example.
!== is the identity operator; so it checks for type too.
But data in $_GET, $_POST, ... arrays are strings. So you need also to check against a string:
if ($type !== "1" && $type !== "2") /* ... */
Also checking if $a !== $x && $a !== $y will be always true (if $x !== $y). So use || here.
Try this:
if (!($type == 1 || $type == 2)) {
header('Location: payment.php');
exit;
}
This can be spoken as Anything other than type is 1 or 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With