www.webdeveloper.com
Results 1 to 3 of 3

Thread: Proper Form For Script

  1. #1
    Join Date
    Oct 2005
    Location
    Knoxville Tennessee
    Posts
    79

    Red face Proper Form For Script

    This aught to be an easy one I am sure.
    In trying to make a dynamic page, what is the proper for for:

    <div class="body">
    <?php @ require_once ("$page.html"); ?>
    </div>
    Obviously this is the body div, then you also do this:

    template.php?page=dogs (template being the overall page name)

    and incuding another page:

    template.php?page=cats

    I think these last two snippets go in the menu section, how are they linked? What is the format?

    If it helps, I am trying to learn from this page
    http://www.alistapart.com/stories/phpcms/
    Last edited by mrwilson; 10-15-2006 at 09:41 PM.

  2. #2
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    well there are two ways to do this , if i am understanding what you want.

    one: using file_exists
    http://php.net/file_exists
    PHP Code:

    <div class="body">
    <?php
    if(isset($_GET['page'])){
      
    $page $_GET['page'];
      if(
    file_exists($page ".html")){
        include(
    $page ".html");
      }else{
        echo(
    "This page is forbiddin");
        die;
       }
      }else{
       echo(
    "This page is forbiddin");
       die;
    }
    ?>
    </div>
    or using switch
    http://php.net/switch

    PHP Code:
    <div class="body">
    <?php
    $page 
    $_GET['page']

    switch 
    $page {
     case 
    "cats"
     
    include ("cats.html");
     break;

     case 
    "dogs"
     
    include("dogs.html");
     break;

    }
    ?>
    </div>
    I wrote both quickly and may have errors

  3. #3
    Join Date
    Oct 2005
    Location
    Knoxville Tennessee
    Posts
    79
    Thanks Sheldon, I will give them a try. I see what you were doing and think the second case will be the most helpful. Very much appreciated.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles