An URL variable is a variable visible from the user into the browser
navigation bar identify from the char "?" + "varname". This is the typical approach using URL variable:
A PHP URL variable is identified from the following code:
$_GET['varname']
Imagine our site have only tree pages: Home, About me, Interests; we want to use URL variables to load the relative pages saved into include folder of our site root (take a look to the complete site structure post).
Copy and paste this code inside the #main section:
"main">
//If is defined URL variable 'aboutme'
if(isset($_GET['aboutme'])){
// include page about me
include('include/in-aboutme.php');
//else if is defined URL variable 'interests'
}else if(isset($_GET['interests'])){
// include page interests
include('include/in-interest.php');
// in all other cases include the home page
} else {
include('include/in-home.php');
}
?>
In this way, when is defined an URL variable that satisfies some criteria (in this case the name), the PHP code load the relative page. In all other cases, or if is not defined a URL variable, load the default page in-home.php (our home page).
In the next lesson I will explain an example of a typical navigation bar that use link with URL variable to navigate on your site.
original content from "http://woork.blogspot.com/2007/10/load-page-using-url-variables-and-php.html"............
ReplyDelete