Jump to content

is_numeric if one of the inputs isn't numeric then echo message!


oobradersoo

Recommended Posts

hello guys just a quick question i have made a html form with php embedded.

 

here is php code:

how could i change the code if 1 of the inputs is'nt numeric then it would echo a message saying

"insert numeric values"

at the minute it echos that if all numeric values are entered.

 

 

elseif(is_numeric($_POST['number1']) && is_numeric($_POST['number2']) && is_numeric($_POST['number3']) && is_numeric($_POST['number4'])){
echo "please insert number";

just realized you had an 'elseif' there.  In that case go back to && instead of || (as I suggested) but put a ! in front of a set of parens wrapping all your tests.

 

elseif (!(test && test && test &&test))

{

   echo error

}

if(null==($number1 && $number2 && $number3 && $number4)){

echo "Please fill in form above?";

}

elseif(is_numeric($_POST['number1']) && is_numeric($_POST['number2'])  && is_numeric($_POST['number3']) && is_numeric($_POST['number4'])){

echo "please put numbers in form";

}

elseif(isset($_POST['number1']) && isset($_POST['number2']) && isset($_POST['number3']) && isset($_POST['number4']))

{echo "answer:" . ($number1+$number2+$number3+$number4);

}

 

 

i want it to proceed to the last elseif!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.