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......
Setting a variable when clicking link
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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
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
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
Straterra
- Forum Regular
- Posts: 527
- Joined: Mon Nov 24, 2003 8:46 am
- Location: Indianapolis, Indiana
- Contact:
Case switch is just a if/then statement. But, ok.
http://us4.php.net/manual/en/control-st ... switch.php
http://us4.php.net/manual/en/control-st ... switch.php
It's better to use GET, POST or what have you rather than REQUEST.Unipus wrote:Also, you might make your life a little easier (and the user's, actually) by rewriting it like so:
Example link:Code: Select all
$link = $_REQUEST['link']; if($link) { include($link . ".php"); } else { include("main.php"); }
<a href="sections.php?link=portfolio">Portfolio</a>
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");
}
?>
Last edited by McGruff on Tue Aug 09, 2005 11:36 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: