SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Me! Php Newb Working On Huge Deadline!

    Okay, so I may be in a little bit of a panic right now, but here's my problem. I'm building a site for a large client and the deadline is in two days. I'm not a big PHP expert, but I created the site in PHP to make things a little bit easier. I built it all on my Apache server with the latest version of PHP, and I kept showing them updates and everything, but then it came down to uploading it to their server today, I realized they were on an IIS server, and my code wasn't working properly.

    I built the content pages into separate pages, and I had a footer and header to wrap around them. Then I used the below code to include the page based on what variable was passed through the URL.

    <? virtual ("$page.php");?>

    The links looked like this main.php?page=resort

    But, the virtual function does not work at all with IIS. I tried using 'include' instead, but that doesn't allow me to use a variable like $page.php in it, so I can't just use main.php?page=resort to view pages.

    What can I possibly do to get around this? ANYONE PLEASE HELP!? I'm sleep deprived and worrying like a crazy man!!

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    include($_GET['page'].'.php'); 
    Aaron Brazell
    Technosailor



  3. #3
    SitePoint Addict phpster's Avatar
    Join Date
    Feb 2005
    Location
    Toronto, Canada
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Build a redirect page that accepts the data from the URL via $_GET['page'] and just runs a header function to move the browser to the new page

    PHP Code:
    <?
    $page 
    ='';

    //default listing of pages in site to check input and handle attempts to break things 
    //by messing with the URL
    $pages = array('resort','contact','about'...);  

    (isset(
    $_GET['page']))? $page $_GET['page'] : $page "default.php";
    if (
    in_array($page$pages){
      
    //send to the requested page
      
    header("location:$page.php");
    }else{
       
    header("location:default.php");
    }
    //end if
     
    ?>
    The default.php can be some error handling page where users get sent if they screw things up or change the url
    phpster

    I wish my computer would do what I want it to.
    Not what I tell it to do...

  4. #4
    SitePoint Member
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    Wow, thanks guys! That was quick too. I really appreciate the help, even though I'm sure its a pretty trivial problem for you guys to answer.

    I'm definitely coming back to this forum more often. I regret not reading it more since I first registered for this account a few years ago.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •