Page 1 of 1

redirect index.php to another page

Posted: Mon Feb 12, 2007 5:57 pm
by tarja311
hey all.

i have an index.php page that contains the following code :

Code: Select all

switch( $show )
{ 
   	case "login"; require( "login.php" ); break;
   	case "logout"; require( "logout.php" ); break;
	case "home"; require( "home.php" ); break;
}
this part works fine. the problem is, when i visit my website ( eg: http://mywebsite.com/ ) i receive a blank index.php page. This means i have to refer everybody to http://mywebsite.com/?show=login. ( i can't perform any output inside index.php or it will show in every page ).

If i set a redirection inside index.php, this also affects all my pages. Is there a way i can make this work so it redirects to the login page when a user visits http://mywebsite.com/ and not touch all the other pages ?

thanks

--tarja

Posted: Mon Feb 12, 2007 6:02 pm
by blackbeard
put a default in that switch statement so that when $show doesn't match anything you have, it will direct to the login page.

Posted: Mon Feb 12, 2007 6:59 pm
by RobertGonzalez

Code: Select all

<?php
switch( $show )
{
  case "login":
    require( "login.php" ); 
    break;

  case "logout": 
    require( "logout.php" ); 
    break;

  case "home":
    require( "home.php" ); 
    break;

  default: 
    // Do what default is if $show is not found
}
?>

Posted: Mon Feb 12, 2007 7:36 pm
by tarja311
That worked. Thanks. :)