3l33tmofo Posted June 5, 2006 Share Posted June 5, 2006 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 | PicturesWhen 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. Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/ Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42123 Share on other sites More sharing options...
3l33tmofo Posted June 5, 2006 Author Share Posted June 5, 2006 thats brilliant thanks! :) Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42143 Share on other sites More sharing options...
3l33tmofo Posted June 5, 2006 Author Share Posted June 5, 2006 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 37Warning: main($content): failed to open stream: No such file or directory in /home/getdowng/public_html/wtf/index.php on line 37Warning: 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 37I'm not really sure what I have to change to make the links load the respective .php file. Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42162 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 try include($content); without the ' '(sorry about the ) was a typo ) Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42165 Share on other sites More sharing options...
3l33tmofo Posted June 5, 2006 Author Share Posted June 5, 2006 That fixed it!Thanks for the fast response :) Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42169 Share on other sites More sharing options...
darkcarnival Posted June 5, 2006 Share Posted June 5, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42185 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 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 metlike [code]$allowedfiles = array('home.php','links.php','pictures.php');$content='home.php'; //default if nothing enteredif ($_GET['content']) { $content=$_GET['content']) . '.php';}$allowed=FALSE;foreach($allowedfiles as $var) { if ($content == $var) { $allowed = TRUE; }}if ($allowed = TRUE) { include($content);}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11257-basic-website/#findComment-42191 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.