Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Create a proper website index page
Old 06-22-2010, 02:28 AM Create a proper website index page
rahulraj's Avatar
Ultra Talker

Posts: 456
Name: RAHUL RAJ
Location: Cochin, Kerala, India
Trades: 0
The typical way to write your index page, if you are not really that knowledgeable in PHP, is just go about coding whatever there is for the index page. For instance, suppose that your index page has a login form and some introductory text. Your approach would be to just write the code for the index page and then, for every link on that page, create another page. This would mean that you now have an index.php page, a contact.php page, a mail.php page and more.

The “index.php?page=home” Way

Instead of having a home.php page, you see something like “index.php?page=home”. The same happens for every page of the website. What happens is that the index.php page includes the code of the other webpages, as asked. The variable page that you notice in the url is actually a typical $_GET type global variable that you can read in order to identify what is the page that the browser asks for.

the actual code of index page would be:

$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 'home';

switch($page)
{
case 'home': break;
case 'mail': break;
case 'contact': break;
default:
$page = 'home';
}

include("$page.php");



The index page just gets the $_REQUEST['page'] global variable ($_REQUEST is a union of $_GET and $_POST, retrieves whatever is available).If an attacker somehow manages to upload a new php page, say hello.php, this index page, without the switch structure, would execute it normally when instructed with index.php?page='hello'. However, if the switch is there, hello.php never gets executed. Instead, the default home.php gets executed. This is always a very good practice and you should really stick to it.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by rahulraj; 06-22-2010 at 02:30 AM..
rahulraj is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-26-2010, 12:46 AM Re: Create a proper website index page
Novice Talker

Posts: 12
Name: Amber Hunter
Location: Fort Worth, TX
Trades: 0
That's really cool!!!

But before I rush off to implement it, how does this affect SEO? Will all of the pages be spidered on your site like they are when doing it the 'old fashioned' way, or just the index page? And does this mean that all PR goes to the index page?
__________________

Please login or register to view this content. Registration is FREE

1706 N. Stemmons Frwy. (I-35E)
Lewisville, TX 75067
amber0hunter is offline
Reply With Quote
View Public Profile Visit amber0hunter's homepage!
 
Old 06-26-2010, 01:42 PM Re: Create a proper website index page
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
how does this affect SEO?
It doesn't!

Quote:
Will all of the pages be spidered on your site like they are when doing it the 'old fashioned' way, or just the index page
Old fashioned way?

Quote:
And does this mean that all PR goes to the index page?
No!


You seem to think that the OP has just developed this method rather than copying and pasting the code

This method has been around as long as PHP has (and longer)!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-28-2010, 04:37 AM Re: Create a proper website index page
Phunk Rabbit's Avatar
Ultra Talker

Posts: 255
Name: John Nerush
Location: Milton Keynes, UK
Trades: 0
For small sites I prefure using header and footer files with variable in the top of the file to overwrite metadata, title etc and structure the folders and files.

For large sites you cant beat the dynamic way like this but as chris says, its as old php and then some. Although there are far more efficient and dynamic ways than using case/break.
__________________

Please login or register to view this content. Registration is FREE

Learn professional skills from professional people, from $6.50 a month.
Phunk Rabbit is offline
Reply With Quote
View Public Profile Visit Phunk Rabbit's homepage!
 
Reply     « Reply to Create a proper website index page
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13861 seconds with 12 queries