Validate input with PHP

-6

I have a question, how can I validate two input in PHP ? The first must validate only these numbers: 00, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10... to number 37. If you enter another number that is not in that line must give error and the second input must validate valid amounts of 50 in 50 up to 5000. Example: 50, 100, 150, 200, 250... to 5000. If you enter an amount that is not in that line, such as 60, 75, 1575 , you must give an error.

if($input < 0 || $input > 37) die('Error');
if($input % 50 != 0 || $input > 5000) die('Error');
    
asked by yoclens 29.05.2017 в 15:58
source

1 answer

0

I've solved it this way:

  else if(!is_numeric($input1) OR $input1 > 37){
          $errMSG = "input invalido.";
  }
  else if(!is_numeric($input2) OR $input2%50!=0 OR $input2> 5000){
         $errMSG = "monto invalido, solo se permiten montos de 50 en 50.";
    
answered by 29.06.2017 / 00:53
source