SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie PHP Static Page index.php Question

    Hello,

    Building an elementary PHP website where the entire site is
    called into one static index.php page. I've gotten this far
    with the script: Basically, uses "get" to grab the title and
    content like this, but not by default:

    index.php?title=MainPage&content=homecontent.php


    Code:
    //
    //
    
    if($_GET['title']){  // CUSTOM GET TO SUPPRESS ERRORS: if Pt is in the URL //
    $pgtitle = $_GET['title']; //  Assign title=$pgtitle // 
    print('<title>'.$pgtitle.': Website.com</title>'); 
    
    //
    //
    
    if($_GET['content']){ // CUSTOM GET TO SUPPRESS ERRORS: if Pg is in the URL //
    $pgcontent = $_GET['content'];  //  Assign content=$pgname // 
                           // $pgcontent specifies the include filename 
    print('<div>');
    include('/fpgs/fpgshttpd/sirpub/sm/includes/'.$pgcontent);// Any File Name Inserted //
    print('</div>');
    
    //
    Problem is that index.php does not have any default title or content,
    HomePage must be called on the address bar. I need it to have default title and content, unless otherwise specified option available.

    I'm no programmer, but would appreciate some advice
    on what to look for, where to look for a script that I can
    download and modify/utilize.

    Please and Thanks,
    Myst

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if(isset($_GET['title'])) ....
    if(isset($_GET['content'])) ...

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CB and all,

    Digging around, but have yet to find a script
    which appears to do the job. The whole site called
    into one static page; Is this rare?

    I'm not trying to call the title from an external script,
    but am trying to call it from and into the main front
    controller script (index.php).

    Can someone please help me, or point me in the
    right direction with just the title, to have a default
    title unless otherwise specified?

    Thanks,
    myst

  4. #4
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never include user input in an include statement unless you validate the living crap out of it first. It's best to use a database or other secure datastore, and address things using numerical values instead. "Bare bones" is okay but not at the expense of security.

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hammer,
    I appreciate the feedback. I'll implement a numerical system
    for the docs, much prettier.

    On this script below, how would I change the script to be able to
    use multiple extensions instead of just txt?

    Code:
    <!-- ?php
    if($_GET['OldPage']){          // if OldPage is in the URL //
    $pageNum = $_GET['OldPage'];   // assign the value of OldPage to the variable // 
                                          // (in this case the value = 1) //
    print('<div>');
    include('staticdoc'.$pageNum.'.txt'); 
    //include staticdoc # whatever is in the URL //
    print('</div>');
    }
    ? -->
    I really need help on configuring these scripts to call a default title name or include doc unless otherwise specified. HELP?

    myst


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
  •