Jump to content

[SOLVED] Can You explain it a better way?


crazyben21

Recommended Posts

Hi I'm reading this online article at http://blog.themeforest.net/tutorials/simple-layouts-with-php/.

 

But I'm a bit confused in understanding "Technique #2". The part I'm confused at is were $_GET['page'] is getting the value from. When I do forms i do know were it is getting the value from. But in this website tutorial I'm confused were do it gets its value from.

 

Can somebody show me how to this technique but in a better way or help me understand it.

 

Thank You

Ben

Link to comment
https://forums.phpfreaks.com/topic/175303-solved-can-you-explain-it-a-better-way/
Share on other sites

In technique #2 they mention:

 

Say this is the URL to our about page: http://domain.com/index.php?page=about

 

Which means that your links should follow a similar format:

 

About


Contact


Pictures

 

Now when a user clicks on "About" you are passing the "page=about" parameter via the URL.  The protocol to retrieve this value is by using:

 

$_GET['page']

 

If you echo this out it will print out exactly "about".  The technique they're using forces you to create files of the exact values for each link (GET parameter).  As a result you can dynamically include your pages.  Hence:

 


 

In which you would include, assuming you click on the "About" link, about.php page.  To illustrate this point you can echo something similar to:

 

echo $_GET['page'] . " .php";

 

NOTE: Be careful with this method as users can inject arbitrary values into the URL parameter.  Hope this helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.