Reputation: 55
I'm trying to compare these three conditions, I need it to not be empty, but be between minus 180 and positive 180, the requests function when its above 180 however not when below. Also reguardless of bad requests the information is still inputted to the database. Any ideas?
Line I need help with:
if(($lat == "") && ($lat < $minval) || ($lat > $maxval)){
header('HTTP/1.1 400 Bad Request');
}
The full code is available here
Thanks in advance
Upvotes: 0
Views: 47
Reputation: 895
You mixed up your operators, and their preference too. Do this:
if(empty($lat) || ($lat < $minval) || ($lat > $maxval)) {
header('HTTP/1.1 400 Bad Request');
//As suggested in the comments, you could also add this
exit();
}
Upvotes: 1