Reputation:
I've been Google-ing this for the past 24 hours, pretty much. I can't seem to find an answer that fits my scenario, even though I know it's widely used.
I have many links on one page (let's call it "page 1") of my website and I would like to them all to head to one, blank page (and this "page 2") and then have the content dynamically load, depending on what link was clicked on the previous page.
All I know is that I need to be able to set a PHP variable with the hyperlinks on page 1 and use some kind of if(isset($_SESSION['phpVariable'])){ include('path/content.fileExt')}
on page 2 page so that it's ready to receive the variable and load the content accordingly.
I just have no clue how to do this, as I only started learning PHP yesterday. Help? :( :L
Upvotes: 3
Views: 5349
Reputation: 9858
You can pass an identifier of the content to be loaded through the URL.
Ex:
Set a value for one of the GET
parameter to be the identifier for the content of page 2
<a href="page2.php?pageid=content">Link to Page 2</a>
And then in page 2 just check for the value and load the content accordingly.
include_once 'content/' . $_GET['pageid'];
Upvotes: 1
Reputation: 4522
You could use the $_GET[]
variable. On page1, the links could be to page2?food=bacon
or page2?food=foo
. On page2, you could say...
if ($_GET['food']=='bacon')
{
// Stuff here that prints what you want.
}
elsif ($_GET['food']=='foo')
{
// Stuff here that prints what you want.
}
Upvotes: 2
Reputation: 590
http://www.w3schools.com/php/php_get.asp
www.example.com/index.php?page=something_here
$_get["page"]
Would return "something_here"
Upvotes: 0