0

I have a short shop form. You can buy there some pens, mugs etc.

After you put a number of items you want to buy I am trying to validate the input information and if it is not correct just change it into 0.

Looks like the !is_numeric function doesn't work, because it always makes the amount 0.

Any help please? Does ! work with this function at all?

$mugAmount = Input::get('mugAmount');

if(!isset($mugAmount) OR $mugAmount = NULL OR !is_numeric($mugAmount) OR $mugAmount < 0){
               $mugAmount = 0;
           };
divHelper11
  • 2,090
  • 3
  • 22
  • 37

1 Answers1

3

It is because of this $mugAmount = NULL. This should be $mugAmount == NULL.

= and == means totally different things ;)

ps: besides you can remove this comparison to NULL because if it is NULL then !isset($mugAmount) will be true :)

nospor
  • 4,190
  • 1
  • 16
  • 25