Computing.Net > Forums > Web Development > pHP SCRIPT

pHP SCRIPT

Reply to Message Icon

Original Message
Name: DJ-BROWNTHUG
Date: May 29, 2004 at 20:39:42 Pacific
Subject: pHP SCRIPT
OS: XP
CPU/Ram: 192
Comment:

hI HOW DO I DO LIKE index.php?Page=Home index.php?Page=LINKS ETC..


Report Offensive Message For Removal

Response Number 1
Name: jam14online
Date: May 29, 2004 at 23:38:57 Pacific
Subject: pHP SCRIPT
Reply: (edit)

When you specify variables after a PHP page like that, you're using the GET feature. You can access Page through this:

$_GET["Page"];

I would write the script you want like so:

<?php

$page = $_GET["Page"];

$page = strtolower($page);

if(empty($page)) include("pages/home.php");

switch ($page) {

case "home":
include("pages/home.php");

case "links":
include("pages/links.php");

case "about":
include("pages/about.php");

default:
include("pages/error.php");

}

?>

However, I don't see the point in doing this unless you have stored all of your pages in a database, e.g. MSAccess or MySQL.

In the example above, it first checks whether the ?Page variable you send to the page is empty. If it is, it just includes the homepage. (So if you just go to index.php, it will send back the homepage.)

Then I check whether the variable is equal to the page names home, links and about (just some examples). If it is, it sends the browser back the page name in the /pages folder. For example, if you specified the about page it would actually send back /pages/about.php but it would look like it was index.php?Page=About.

If the page is an unknown page (e.g. sakdsjksd) then it sends back an error page to say so. You could link this to the home page instead but I think it's more professional to do it this way and you could include your site design on this page so it blends in anyway.

I hope this helps,


James



Report Offensive Follow Up For Removal

Response Number 2
Name: DJ-BROWNTHUG
Date: May 30, 2004 at 13:51:35 Pacific
Subject: pHP SCRIPT
Reply: (edit)

Ty it really helpd me ty a lot


Report Offensive Follow Up For Removal

Response Number 3
Name: DJ-BROWNTHUG
Date: May 30, 2004 at 14:09:57 Pacific
Subject: pHP SCRIPT
Reply: (edit)

Hi again sorrey he script n not working again try the link http://brownthug.ibfreeuk.com/Index2.php


Report Offensive Follow Up For Removal

Response Number 4
Name: DJ-BROWNTHUG
Date: May 30, 2004 at 16:43:21 Pacific
Subject: pHP SCRIPT
Reply: (edit)

N\m it works


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: pHP SCRIPT 

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software