SitePoint Sponsor

User Tag List

Results 1 to 17 of 17

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple PHP include statement

    I'm not very familar with PHP in terms of code writing, so I'm curious about something.

    On my website, www.bui4ever.com, I'm using <? include('name of document.txt'): ?> in place of where I change information frequently. I then input the information into a text document and link it to that line. I do it so when I alter the text, I don't have to risk messing with the layout. Is there any forseeable problems I may run into in the future doing it this method? I don't really need a database or anything fancy like that. Thanks!

  2. #2
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not really. What I thi8nk you're looking for is a Content Management System, or CMS.

    Try Mambo.

  3. #3
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No I don't really want a CMS. Already did Postnuke. I want a website fully created by me. I was just figuring a way to make some changes to certain areas more efficiently. For example, the side navigation on the index page is the same as the sub menu on those 10 pages. In the past, to add one new menu block, I would have 10 pages to update. By making it into a txt doc and calling upon it with the php line, I now only have to change 1 doc for 10 pages. Basically the same idea as an external style sheet. I just want to make sure that that PHP line isn't going to cause problems on different browsers, or other issues.

  4. #4
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, then it's fine, I do it on some of my sites as well.

  5. #5
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Coolio! Thanks Dylannn!

  6. #6
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I would do, however, is not make it a .txt file, but make it a .html file. This is so if I want to just look at the content alone, i can still see it formatted in the browser window.

  7. #7
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hrmmm...that sounds like a good idea. I think I will do that.

  8. #8
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you start passing variables to this include() function, make sure you cleanse that data thoroughly to prevent users from opening files they shouldn't be. You can use regular expressions to verify that or, if there are only a few options, put those options into an array and make sure that the variable passed is in that array.
    Brock Ferguson
    Lead Developer, Caribou CMS
    A Subscription/Membership CMS and Ecommerce Platform - FREE Trial

  9. #9
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ToolboxTech
    If you start passing variables to this include() function, make sure you cleanse that data thoroughly to prevent users from opening files they shouldn't be. You can use regular expressions to verify that or, if there are only a few options, put those options into an array and make sure that the variable passed is in that array.
    It didn't sound like she was going to be using any variables in the include; I think she just wanted to seperate her content from her layout.

    EDIT: I also don't think there is going to be any user input to clense.

  10. #10
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylannn
    It didn't sound like she was going to be using any variables in the include; I think she just wanted to seperate her content from her layout.

    EDIT: I also don't think there is going to be any user input to clense.
    Actually I'm a he

  11. #11
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by peiqinglong
    Actually I'm a he
    LIES!!!





































    My bad.

  12. #12
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylannn
    LIES!!!




































    My bad.
    No worries...sorry to bust your bubble tho.

  13. #13
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dylannn
    It didn't sound like she was going to be using any variables in the include; I think she just wanted to seperate her content from her layout.

    EDIT: I also don't think there is going to be any user input to clense.
    Yes I know that he didn't plan on using user input now but it's the natural progression from this step so it's better to be safe than sorry.
    Brock Ferguson
    Lead Developer, Caribou CMS
    A Subscription/Membership CMS and Ecommerce Platform - FREE Trial

  14. #14
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...that is beyond my knowledge right there. Do you have any articles or tutorials I can read to familiarize myself with how to do that?

  15. #15
    SitePoint Enthusiast
    Join Date
    May 2004
    Location
    Ontario, Canada
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not as complex as it sounds. You basically just want to know what the people are trying to pass as a variable.

    It's covered very well in Shiflett's PHP Security Guide (55 Page PDF).
    Brock Ferguson
    Lead Developer, Caribou CMS
    A Subscription/Membership CMS and Ecommerce Platform - FREE Trial

  16. #16
    SitePoint Addict DM3Dan's Avatar
    Join Date
    Sep 2004
    Location
    Albany, NY
    Posts
    204
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure you change your file extension to index.php instead of html.

    Not that I've ever forgotten to do that or anything

  17. #17
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most of my pages are all PHP because I'm running some PHP scripts already.


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
  •