Jump to content


Photo

Basic Website


  • Please log in to reply
7 replies to this topic

#1 3l33tmofo

3l33tmofo
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 June 2006 - 06:36 PM

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.

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 June 2006 - 06:55 PM

for your links:
<a href='index.php?content=home'>Home</a>
<a href='index.php?content=links'>Links</a>
<a href='index.php?content=pictures'>Pictures</a>

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


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 3l33tmofo

3l33tmofo
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 June 2006 - 07:26 PM

thats brilliant thanks! :)

#4 3l33tmofo

3l33tmofo
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 June 2006 - 07:51 PM

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.

#5 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 June 2006 - 08:00 PM

try include($content); without the ' '

(sorry about the ) was a typo )
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#6 3l33tmofo

3l33tmofo
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 05 June 2006 - 08:07 PM

That fixed it!

Thanks for the fast response :)

#7 darkcarnival

darkcarnival
  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 05 June 2006 - 09:14 PM

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.

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 05 June 2006 - 09:27 PM

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
$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);
}

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users