Page 1 of 1

Nothing to $_GET[] - Solved

Posted: Thu Apr 03, 2008 11:00 am
by psurrena
I think I might have painted myself into a corner. In streamlining my site, everything runs off two switch statements on a template page, which happens to be my index page. I use mod_rewrite to switch my "modes". So, index.html = index.php?mode=1. The problem is if you go to http://www.mysite.com, index.html is not in the url...nothing to rewrite. My idea was, if there is nothing to get, then set the variable to 1 but it doesn't seem to work. Any ideas?

Code: Select all

 
if(isset($_GET['mode'])){
    if(!is_numeric($_GET['mode'])){
        error("numeric");
    }else{
        $mode=$_GET['mode'];
    }
}else{
    $mode=1;
}
 

Re: Nothing to $_GET[]

Posted: Thu Apr 03, 2008 11:49 am
by psurrena
Nevermind, I was over complicating everything and just ended up simplifying. Here is the function code if anyone was interested:

Code: Select all

 
if(isset($_GET['mode'])){
    if(!is_numeric($_GET['mode'])){
            error("numeric");
    }else{
        $mode=$_GET['mode'];
    }
}
            
switch($mode){
    //work
    case("2"):
        require_once('./pages/work.php');
        break;
    
    //Tutorials
    case("3"):
        require_once('./pages/tutorials.php');
        break;
    
    //Contact   
    case("4"):
        require_once('./pages/contact.php');
        break;
    
    //Home
    default:
        require_once('./pages/default.php');
        break;
}