lundi 13 août 2018

PHP:complex logical operators with grades

I want to check my if statement , I've spent a long hour and I just got more confused. The problem is that there's two inputs, midterm and final grades and both of them should be between 1.0 and 5.0, can be DR, NG, NA, W and nothing else.

if(isset($_POST["save"])){
        // echo 'nana';
        $mgs = $_POST["midg"];
        $fgs = $_POST["finalg"];
    if(((floatval($mgs)<5.0 && floatval($mgs)>=1)||($mgs!=""&&($mgs=="DR"||$mgs=="NA"||$mgs=="NG"||$mgs=="W")))&&(floatval($fgs)<5.0 && floatval($fgs)>=1)||($fgs!=""&&($fgs=="DR"||$fgs=="NA"||$fgs=="NG"||$fgs=="NW"))){
   echo " valid inputs";

    }
else{

echo "invalid inputs";
}

Aucun commentaire:

Enregistrer un commentaire