Page 2 of 2

Posted: Sat Jan 17, 2004 2:34 pm
by John Cartwright
Okay I ran into a different problem.

Okay im in index.php?link=2 which is my portfolio section


now I need to get to a link which is index.php?item=2. After I put the 2nd code ( for items ) and I try to load the portfolio section ( link=2) then the page simply keeps on loading itself adding more and more repeated content. I have absolutely no idea how to get around this. Is it not possible to have the same index.php?link= and portfolio.php?link=


sorta confusing......

Posted: Sat Jan 17, 2004 2:38 pm
by John Cartwright
Okay nevermind I fixed the logic behind it... but now I ran into yet another problem.

When I click on the second set of links calling up the items=
......grrr so hard to explain......

okay you have index.php?link=2 which calls up portfolio.php

so its index.php?link=2 with the portfolio content displayed. Portfolio also have links calling up portfolio.php=item2 but when I call up that it only brings up the portfolio.php and the new item and not index.php. I understand why it is not working but I do not have the experience to get around this. Help is much appreciated.. .you know I love you guyys

Posted: Sat Jan 17, 2004 2:40 pm
by Straterra
Sure you can...do this

index.php?link=2&content=1

Just request content and do another if/then statement (case/switch) and it should work.

Posted: Sat Jan 17, 2004 2:46 pm
by John Cartwright
I've heard about this case/switch stuff... can you refer me to a link so I can learn more about this?

Posted: Sat Jan 17, 2004 3:08 pm
by Straterra
Case switch is just a if/then statement. But, ok.
http://us4.php.net/manual/en/control-st ... switch.php

Posted: Sat Jan 17, 2004 3:37 pm
by McGruff
Unipus wrote:Also, you might make your life a little easier (and the user's, actually) by rewriting it like so:

Code: Select all

$link = $_REQUEST['link']; 
      if($link)
      {
            include($link . ".php");
      } else
      {
            include("main.php");
      }
Example link:
<a href="sections.php?link=portfolio">Portfolio</a>
It's better to use GET, POST or what have you rather than REQUEST.

Be careful about including file names passed via GET: it's very easy to tamper with the query string and so any php file could be included in the above snippet.

Adding a prefix deals with this:

Code: Select all

<?php

      if(isset($_GET['link']))
      {
            include('prefix_' . $_GET['link'] . '.php');
      
      } else {

            include("main.php");
      }

?>

Posted: Sat Jan 17, 2004 6:09 pm
by John Cartwright
much better ty