PDA

View Full Version : Includes? or something...



Nli.
27-10-2008, 07:53 PM
I ain't done web design for age, so I've basically forgot most things or just got little bit's of information.

Right ages ago around about Jan/Feb I think Invent! owned a webdev website or something, I requested something to do with PHP includes so that when I clicked a link it opened in a content box or whatever.

I was hoping someone could help me with this by posting the PHP.
Thanks, and plus rep.

Nli.
28-10-2008, 08:44 PM
Oh and I forgot to mention, in the nagiation your link would be like index.php?p=home.php or something like that... if that helps? :S

Nli.
01-11-2008, 11:35 AM
Umm... Bump maybe? xD

Invent
01-11-2008, 05:06 PM
Hi,

If you want to have a script that parses the url '?page=about' and loads the file about.php in a content area then use a piece of code like this:



<?php

$page = $_GET[ 'page' ];

$clean = array( '/', '.', ':' );

if( isset( $page ) && $page != '' )
{

if( file_exists( './' . $page . '.php' ) )
{

include './' . $page . '.php';

}
else
{

include '404.php';

}

}
else
{

include 'home.php';

}

?>

Want to hide these adverts? Register an account for free!