Help! PHP Layout Includes

Discussion in 'PHP' started by WebDivx, Nov 17, 2006.

  1. #1
    i just moved to a new host and my php layout includes don't show! i changed my paths to the new ones and i dont get any errors or anything, it just doesn't show!

    does anybody know a robust and secure php layout includes code? One that calls a cetain page, and if that page doesn't exist it calls another page.

    Like you know when you go to a website they have the latest news on the main page and then the content area changes, but the layout stays the same, as they go to different pages. And the page url changes lfrom like http://www.site.com to http://www.site.com/index.php?m=pagename as you go from the main page to another part of the site.

    Please help!! I will positive rep you! Thanks!!!
     
    WebDivx, Nov 17, 2006 IP
  2. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #2
    
    if(!@include 'first_page.php')
    {
      include 'second_page.php';
    }
    
    PHP:
     
    SoKickIt, Nov 17, 2006 IP
    WebDivx likes this.
  3. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Can you post a piece of code where $page & $id are defined?
     
    SoKickIt, Nov 18, 2006 IP
  4. WebDivx

    WebDivx Peon

    Messages:
    212
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i don't understand what you mean by defined?

    By the way, the include function works on the site and I get the news to show up, however the "else" function does not seem to work. Is their an alternative to the "else" or is something on my site turned off that si supposed to be on?
     
    WebDivx, Nov 18, 2006 IP
  5. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #5
    You probably have:

    $page = something...
    $id = something...

    before include...
     
    SoKickIt, Nov 18, 2006 IP
  6. WebDivx

    WebDivx Peon

    Messages:
    212
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i actually don't have that. and my site worked perfectly on the shared hosting.
     
    WebDivx, Nov 18, 2006 IP
  7. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sounds like you had register_globals set ON on your old host (and it's now set OFF).

    register_globals set ON is a security issue, but you can normally override it with a line in your .htaccess file, I believe.
     
    TwistMyArm, Nov 18, 2006 IP
    WebDivx likes this.
  8. WebDivx

    WebDivx Peon

    Messages:
    212
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Do you know how to access register_globals? Is that in the php.ini file?

    I created a new code that works though, so thanks for the help
     
    WebDivx, Nov 18, 2006 IP
  9. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Firstly, you can set it in PHP.INI to affect the entire installation. If you have it disabled on the site but want it enabled for a single directory (and all of its subdirectories) you can add the line:

    php_flag register_globals off

    to a .htaccess file in that directory.

    It's not recommended use and according to http://ca3.php.net/manual/en/ini.core.php#ini.register-globals it doesn't even exist in PHP6.
     
    TwistMyArm, Nov 18, 2006 IP
  10. legend2

    legend2 Well-Known Member

    Messages:
    1,537
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    115
    #10
    You can always use the function file_exists in order to check if a file is there.

    ex:


    But what you can do in your example is, http://www.site.com/index.php?m=pagename is specifying you need to include the content of "pagename".

    So you can do:

     
    legend2, Nov 19, 2006 IP