PHP IF-Statement doesnt work like i want -


this question has answer here:

i started writing website learning html/css/js/php.

i designed front-end of site bootstrap. trying validate inputs php.

i tried this:

    if ($durationhh <= 0 && $durationmm <= 0)     {         echo "durationhh , durationmm can not both 0 @ same time.";             echo "<br>";         echo "durationhh , durationmm can not smaller 0.";            }     elseif (empty($durationhh) || empty($durationmm))     {                echo "durationhh , durationmm can not empty.";         echo "<br>";     }     else     {         echo $_post["durationmm"];         echo ":";         echo $_post["durationhh"];     } 

i tested validation putting in values durationhh , durationmm.

everything working fine far, except these 2 cases:

durationmm = 0 , durationhh = value

&&

durationhh= 0 , durationmm = value.

in these 2 cases output: "durationhh , durationmm can not empty."

how/why happen?

if durationhh , durationmm required integers or numeric, use ! is_numeric() check.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -