Re: Applying the elseif and switch statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gab, for your comparisons you need to be sure to have two equals signs (==, not =), otherwise it becomes an assignment and always returns 'true'.
--- In php-objects@xxxxxxxxxxxxxxx, Gab Teo <doneatlast1000@...> wrote:
>
> Hello,
>  
> I created a page that will enable users to go to the page of the item they chose as mean with their passcode (username and password),  and I used the elseif statement and the switch statement.
>  
> 1. For  the elseif statemnet, the output seems to be the same as it take me to:  header("Location:ordinarily.php");
> irrespective of the mean chosen
> 2.  And again for  the switch statemnet, the output seems to be the same as well, it take me to:   header("Location:simple.php");
> irrespective of the mean chosen
>  
> 
> can anyone figure out what I need to put right
> Thanks,
> Gab
>  
> <?php
> if (!empty($_POST[Submit]))
> {
> include ("databaseconnect.php");
> $username=$_SESSION[12345];
>  
> $page=mysql_query("SELECT * from mean where mean='$mean'");
>  
> if(mysql_num_rows($page)==0)
> echo"<ul><font color=red><b>Not available</b></font></ul>";
>  
>  
> $mean= "ordinarily";
> $mean = "major";
> $mean = "simple";
>  
>    elseif ($mean = "ordinarily") 
>    {
>    header("Location:ordinarily.php");
>   }
>    elseif ($mean = "major") 
>    {
>    header("Location:major.php");
>   }
>   elseif ($course = "simple") 
>    {
>    header("Location:simple.php");
>   }
> else
> echo"Rgister for mean";
>    }
> }
> 
>  
> ?>
>  
> The switch statement
>  
> 
> <?php
> if (!empty($_POST[Submit]))
> {
> include ("databaseconnect.php");
> $username=$_SESSION[12345];
>  
> $page=mysql_query("SELECT * from mean where mean='$mean'");
>  
>  
> if(mysql_num_rows($page)==0)
> 
> echo"<ul><font color=red><b>Not available</b></font></ul>";
>  
> $mean= "ordinarily";
> $mean = "major";
> $mean = "simple";
>  
> switch ("$mean")
>  {
>    case "ordinarily" :
>    header("Location:ordinarily.php");
>    break;
>    case "major" :
>    header("Location:major.php");
>    break;
>    case "simple" :
>    header("Location:simple.php");
>    break;
>    default :
>    echo"Rgister for mean";
>    break;
>    }
> }
> 
> ?>
> 
> 
> 
>       
> 
> [Non-text portions of this message have been removed]
>



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux