Page 1 of 1

A litte help please...

Posted: Fri Mar 20, 2009 11:21 am
by B17BR34K
I'm trying to make a simple link system on my website. My friend had coded this previously and it worked. I basically tried to recode it myself with a little help from him over a chat session and for some reason it's just not working. If someone could help point out what I'm doing wrong, I would appreciate it very much.

$page = 'home.php';
$link = 'home'; <====== was $_GET['home.php']; but I changed it.

if ($link == 'home'){
$page = 'home.php';
}

if ($link == 'links'){
$page = 'links.php';
}

if ($link == 'about'){
$page = 'about.php';
}

include $page;


It's not giving me any errors... It's just not pulling up the content from the other php files. Maybe I should change the page= to use the $_GET variable?

Re: A litte help please...

Posted: Fri Mar 20, 2009 11:29 am
by temidayo
try putting double quote around the variable in front of the include like this:

Code: Select all

include "$page";

Re: A litte help please...

Posted: Fri Mar 20, 2009 11:41 am
by B17BR34K
Actually I forgot to mention that that's probably the only thing that works. It's including the home page, the links just aren't changing to the content that I have in the other php files.

<a href="test.php?link=home">HOME</a><br />
<a href="test.php?link=links">LINKS</a><br />
<a href="test.php?link=about">ABOUT</a>

Those are the links I'm using. The php files are located in the same directory as test.php.

Re: A litte help please...

Posted: Fri Mar 20, 2009 11:57 am
by temidayo
what you are suppose to do then is

Code: Select all

$link = $_GET['link'];
Put that code at the very line you changed.
B17BR34K wrote: $link = 'home'; <====== was $_GET['home.php']; but I changed it.

Re: A litte help please...

Posted: Fri Mar 20, 2009 12:07 pm
by B17BR34K
temidayo

Thanks, that fixed the problem. I guess my friend didn't remember how he had coded it the first time. :D

Re: A litte help please...

Posted: Fri Mar 20, 2009 12:19 pm
by temidayo
You are welcome!