Jump to content

Archived

This topic is now archived and is closed to further replies.

3l33tmofo

Basic Website

Recommended Posts

Hi im attempting my first php website for a friend of mine for his clan.

I want the site to be as simple and flexible as possible and I have one question which i'm sure has a simple solution. I want there to be an index page which will have 3 tables with an include in each one.

The first include is just a header which can be updated as is the second table which is the menu.
The third table is my question. I want this to be my content and I want the include to change inrespect to the links pressed on the menu.

So say my menu is this: Home | Links | Pictures
When they click the Home link, the include in the 3rd table will be <?php include('home.php'); ?>
When they click Links home.php will change to links.php.

I have no idea how to do this but its needed so that everything can be updated without need to change the layout.

Many thanks. Matt.

Share this post


Link to post
Share on other sites
for your links:
[code]
<a href='index.php?content=home'>Home</a>
<a href='index.php?content=links'>Links</a>
<a href='index.php?content=pictures'>Pictures</a>
[/code]

for your include:
[code]
$content='home.php';
if ($_GET['content']) {
   $content=$_GET['content']) . '.php';
}
include('$content');
[/code]

Share this post


Link to post
Share on other sites
I seem to be having a problem.

The first one was an inexpected ")" so i deleted that.

Now i get an error:

Warning: main($content): failed to open stream: No such file or directory in /home/getdowng/public_html/wtf/index.php on line 37

Warning: main($content): failed to open stream: No such file or directory in /home/getdowng/public_html/wtf/index.php on line 37

Warning: main(): Failed opening '$content' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/getdowng/public_html/wtf/index.php on line 37

I'm not really sure what I have to change to make the links load the respective .php file.

Share this post


Link to post
Share on other sites
a huge thing to know first.

be sure to clean the varible first to ensure no one enters an invalid entry.

the way listed above will cause you to get attacked in a snap.

though another simple method is to draw out the data from mysql. if you want more info on this, just ask.

Share this post


Link to post
Share on other sites
you can basically do a check on the $content to see if it matches only the files you want it to match, and include it only if the condition is met

like
[code]
$allowedfiles = array('home.php','links.php','pictures.php');

$content='home.php'; //default if nothing entered
if ($_GET['content']) {
   $content=$_GET['content']) . '.php';
}

$allowed=FALSE;
foreach($allowedfiles as $var) {
  if ($content == $var) {
     $allowed = TRUE;
  }
}
if ($allowed = TRUE) {
   include($content);
}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.