Jump to content

Archived

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

lurah

IF inside IF

Recommended Posts

Hi all.
I have tried to search answer but havent got this solved.
write.php receives $_POST values from another file. Values are passed as should. I tested many times with echo $value.

[code]if (($cat != "new")  && ($newcat != ""))
                  { 
                          echo "Select \"New category\" to create it.<br>";
                          $false++;
                    }
[/code]

[code]if ($cat_new != "")
          {
                  if ($cat != "new")
                  { 
                          echo "Select \"New category\" to create it.<br>";
                          $false++;
                    }
          }
[/code]

Both ways, i allways end up on $false++ even the values are right.
So the idea is, that if $cat_new != "", then $cat must be "new" or $false increases.

Share this post


Link to post
Share on other sites
Well there a couple of options you can go

if(){
elseif() {

}

}

or in this case i would go with switch statements


switch($_POST){
case $cat != "new":
echo "yep"
breal;
case empty($cat):
echo "empty";
break;

}

in a rush so search google.com for php switch statement tutorial

Share this post


Link to post
Share on other sites
Are you checking if register globals is on??

Maybe you need...
[code]
<?php

if (($_POST['cat'] != "new")  && ($_POST['newcat'] != ""))
                  { 
                          echo "Select \"New category\" to create it.<br>";
                          $false++;
                    }
?>
[/code]

Share this post


Link to post
Share on other sites

×

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.