Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.