SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP Code

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Code

    Hi, I'm new to this so bare with me. This code is supposed to call the page like this /index.php?page=main.html but it's doing it this way index.php?pages=main.html. Could someone please help me with this? I do have a pages folder.




    Code PHP:
    <?php
     
    if (isset($_REQUEST['page']))
    { 
    if($_REQUEST['page'] !="")
    if(file_exists("pages/" .$_REQUEST['page'].".html"))
    $page_content = file_get_contents("pages/" .$_REQUEST['page'].".html");
    else
    if (file_exists($_REQUEST['page'].".html"))
    $page_content = file_get_contents($_REQUEST['page'].".html");
    else
    echo "<center>Page:".$_REQUEST['page']." does not exist! Please check the url and try again!</center>"; 
    }
    else
    $page_content = file_get_contents("pages/main.html");
    $page_content = str_replace("!!HEADER!!", file_get_contents("design/header.html"),$page_content);
    $page_content = str_replace("!!LEFT_COLUMN!!", file_get_contents("design/left_column.html"),$page_content);
    $page_content = str_replace("!!RIGHT_COLUMN!!", file_get_contents("design/right_column.html"),$page_content);
    $page_content = str_replace("!!FOOTER!!", file_get_contents("design/footer.html"),$page_content); 
    $page_content = str_replace("!!COMMON_TAGS!!", file_get_contents("design/common_tags.html"),$page_content);
     
    echo $page_content;
     
    ?>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,036
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    folder slash

    I'm a bit confused. The code doesn't show any "index.php" in it with or without the leading slash. If you mean "pages" doesn't have the leading slash, you could try adding it
    PHP Code:
    if(file_exists("/pages/" .$_REQUEST['page'].".html"))
    $page_content file_get_contents("/pages/" .$_REQUEST['page'].".html"); 


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
  •