Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2002
    Location
    Las Vegas
    Posts
    797

    create index.php?act=PAGE

    Hello,

    The how too file here in WHT is a little outdated

    i like to create txt file and drop them in say "include" folder switch will auto create index.php?act=PAGE

    Any updated how too will be great

    thanks
    Last edited by P-nut; 11-04-2006 at 06:21 PM. Reason: typo

  2. #2
    Join Date
    Sep 2005
    Posts
    550
    well you can do:

    Code:
    if (empty($_GET['act'])) { require "includes/index.php"; }
    elseif ($_GET['act'] == "PAGE') { require "includes/PAGE.php"; }
    Keep adding elseif's for every page you want.

  3. #3
    Join Date
    Oct 2006
    Location
    Newcastle, England
    Posts
    21
    The way I always do it is similar but it is:
    Code:
    if(empty($_GET['act'])){
       include'include/index.txt';
    }else{
       include'include'.$_GET['act'].'.txt';
    }

  4. #4
    Join Date
    Apr 2002
    Location
    Las Vegas
    Posts
    797
    Quote Originally Posted by groomi
    The way I always do it is similar but it is:
    Code:
    if(empty($_GET['act'])){
       include'include/index.txt';
    }else{
       include'include'.$_GET['act'].'.txt';
    }

    thats what i was looking for (works great)

    now how can get to redirect back to home page if they use the wrong url

  5. #5
    Join Date
    Oct 2006
    Location
    Newcastle, England
    Posts
    21
    Quote Originally Posted by Ivan23
    thats what i was looking for (works great)

    now how can get to redirect back to home page if they use the wrong url

    for that i'd use .htaccess Create a file in your server root called ".htaccess" you may already have this file..
    In it i'd put

    Code:
    ErrorDocument 404 /index.php
    *edit* this will only work if you are using an apache server on linux

  6. #6
    Join Date
    Apr 2002
    Location
    Las Vegas
    Posts
    797
    ah i see what your saying, thank you

  7. #7
    Join Date
    Oct 2006
    Location
    Newcastle, England
    Posts
    21
    no problem, hope it works

  8. #8
    I am using a index.php file with this code inside. The main.php is a default page displayed when "act" parameter is empty.

    PHP Code:
    switch ($_GET['act']): 
    case 
    "PAGE":
    include(
    "PAGE.php");
    break;
    case 
    "PAGE1":
    include(
    "PAGE1.php");
    break;
    default:
    include(
    "main.php");
    endswitch; 

Posting Permissions

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