post - PHP code how to clean user input from $_POST -


i have php code:

<?php     $score11 = $_post['passmarks12'];      if($_post['passmarks12'] > 100){         $grade11 = "";     }     elseif ($_post['passmarks12'] < 45){         $grade11 = "fail";     }     $strg = " $grade11";      echo $strg;  ?> 

the code printing "fail" regardless of sent in.

i want if passes in blank or invalid input fails.

and how should cleanse input?

this php code make sure $_post not empty before comparing 100.

<?php     $score11 = $_post['passmarks12'];      if(empty($_post['passmarks12']) || $_post['passmarks12'] > 100)         $grade11 = "";      elseif ($_post['passmarks12'] < 45)         $grade11 = "fail";      $strg = " $grade11" ;      echo $strg;  ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -