Jump to content

Basic Website


3l33tmofo

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.
Link to comment
https://forums.phpfreaks.com/topic/11257-basic-website/
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]

Link to comment
https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42123
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.
Link to comment
https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42162
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]
Link to comment
https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42191
Share on other sites

Archived

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

×
×
  • Create New...

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.