x10Hosting Forums

Corporate Free Hosting for the Masses.



Register

Reply
 
LinkBack Thread Tools Display Modes
x10 Elder

VPmase's Avatar

Join Date: Nov 2007
Posts: 832
Credits: 17,400
VPmase will become famous soon enough
Location: Dixon, IL, USA

Send a message via MSN to VPmase
Quote  
05-01-2008, 10:41 PM
Load Pages from one Page via URI

In this tutorial I'm going to show you how you can have people only go through one page for your entire website.
Functions use:
1) if/then/else
2) switch
3) Global Vars
4) isset
5) in_array
6) include
7) die

I'll show the code then explain it.

PHP Code:
$page "home";
if(isset(
$_GET['p'])){
$page $_GET['p'];
}
?> 
That section of code sets the $page variable, which will is very important, to the URI if it is set. (URI is the part of the URL after the ?, in this case it would be "?p=*page*")
Thats a good start, but it is not very secure... Lets make it safer, shall we?

PHP Code:
$allowedpages[0] = "home"//You can change this to your page names
$allowedpages[1] = "other"//You can change this to your page names
$allowedpages[2] = "other2"//You can change this to your page names

$page "home";
if(isset(
$_GET['p']) && in_array($_GET['p'], $allowedpages)){
    
$page $_GET['p'];
}

include(
$page ".html") or die("Could not find page!"); // You can change the .html to your pages' extentions 
The end of that code is what loads the actual page or if the page doesn't exist it stops the page and displays the error message associated with the problem.

Demo: http://saumpro.com/scripts/other/uritut/main.php
__________________
Visit my site!
Always use the search function before posting a new thread!
Extra10 | BuxBank | NeoBux

Extra10 | BuxBank | NeoBux
Help me out <3
Helpful suggestions: Read the rules on every forum, follow said rules, and if you are unsure or need help, search first
Reply With Quote
VPmase is offlineReport Post
x10Hosting Member

Join Date: Apr 2008
Posts: 3
Credits: 15
luckym is on a distinguished road
Quote  
05-02-2008, 02:35 AM
Re: Load Pages from one Page via URI

How about doing it without the error message?

Code:
if(@is_file($page.".html") == true){ // Checks if the file exists.
      include($page . ".html"); //Load up the intended page
}else{
      include("home.html"); //Load up your default page
}
Reply With Quote
luckym is offlineReport Post
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
No more custom error pages!? pasacom Free Hosting 3 03-12-2008 01:50 PM
I need help with public viewing of my page Squeaky Neb Scripts & 3rd Party Apps 3 10-02-2007 09:24 PM
How Estonian webhost closed down BRUTUALY not 1, 2, 3 or 4, but 5 Webgames! t2t2t Off Topic 3 11-29-2006 02:38 AM
vBulletin - Optimization !!!!! bin_asc Scripts & 3rd Party Apps 7 08-05-2005 05:27 AM


All times are GMT -5. The time now is 05:17 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0 RC7
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

Credit Cards | Loans | Mobile Phone | Myspace Codes | Cash ISA