Nothing to $_GET[] - Solved

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Nothing to $_GET[] - Solved

Post 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;
}
 
Last edited by psurrena on Thu Apr 03, 2008 11:49 am, edited 1 time in total.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Re: Nothing to $_GET[]

Post 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;
}
 
 
Post Reply