mercredi 5 décembre 2018

how to validate variable values with php

I currently have a problem with my validation if statement. I can confirm that the values that the user selects is being stored so that not the problem.

When I try test this it always prints "1" as the first test was to insert string data into $var3 and $var4 and $var5 to see which should echo 2 , but it does not.

if(empty($Var1) || empty($Var2) && empty($Var3) || empty($Var4) && !empty($Var5))
    {

      echo "1";


    }   
    elseif(empty($Var1) || empty($Var2) && !empty($Var5) && !empty($Var3) && !empty($Var4)) 
    {

      echo "2";
    }
    elseif(empty($Var3) || empty($Var4) && !empty($Var5) && !empty($Var1) && !empty($Var2))
    {

       echo "3";
    }

    else
    {

     echo "4";
    }

Aucun commentaire:

Enregistrer un commentaire