if statement - Error in logical or in if condition in PHP -


i have file category.php passes get['cat'] parameter process_edit.php

process_edit.php has code inside..

if (!isset($_get["cat"]) || !isset($_get["new_field"])) {     header ("location: category.php");      exit;     }    else {           if (! ctype_digit($_get["cat"])) {          header("location: category.php");         exit;      }    } 

but, when pass 'cat', going in first if statement rather going in else part.

can 1 suggest what's error ?

let's break down :

if (!isset($_get["cat"]) || !isset($_get["new_field"])) { 

this means, if cat not set, or new_field not set, condition true.

if pass cat, don't pass new_field, condition still true. if want false, need send both cat , new_field.

the && requires conditions must true return true, else returns false.

the || requires of given conditions must true return true, else returns false.

you can find complete reference of php logical operators here :

http://php.net/manual/en/language.operators.logical.php


Comments