Jump to content

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


Go to solution Solved by ginerjm,

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.