Code: Select all
http://sitename.com/?=guideI have read some tutorials on the $_get[] functions. But I do no't know how to use it for linking other php but using the "?=" instead of "guide.php"
Moderator: General Moderators
Code: Select all
http://sitename.com/?=guideCode: Select all
<?
if(isset($_GET['isitfriday'])){ //check to see if the value is friday or not
$isitfriday = $_GET['isitfriday'];
if(strtolower($isitfriday) === "yes"){
echo "Thank god it's FRIDAY!!!"; //if=yes echo
}else{
echo "Not quite Friday yet."; //if!=yes echo
}
}else{ //if there is no value set, then echo links.
echo "<a href=\"page.php?isitfriday=yes\">If today is Friday, click here</a><br><a href=\"page.php?isitfriday=no\">If today is not Friday, click here</a>";
}
?>Code: Select all
http://mywebsite.com/myDirectory/index.php
http://mywebsite.com/myDirectory/Code: Select all
http://mywebsite.com/myDirectory/?page=guideCode: Select all
http://mywebsite.com/myDirectory/index.php?page=guideCode: Select all
<?php
if(!isset($_GET['page']){
$page = "index"; // if there is no page specified, use the default page
}else{
$page = $_GET['page']; // if there is a page specified by $_GET, use it instead.
}
/*
* This is where you can now call each page as you need it.
* There are many ways in which you can do this, but if you
* wanted to INCLUDE a file 'guide.php' when the page specified
* is 'guide', then you would use something like this.
*/
if($page == "guide"){
include_once("guide.php");
}elseif($page == "info"){
include_once("info.php");
}else{
include_once("index.php"); // the index page is only shown if no other pages are specified.
}
?>Code: Select all
<?php
if( isset($_GET['page']) ):
$page = $_GET['page']; // pass the value of $_GET['page'] to a local variable for easy use;
switch($page): // use a switch condition to refer pages from the var $page
case 'home':
include_once('home.php');
break;
case 'guide';
include_once('guide.php'); // load the guide page
break;
case 'about us';
include_once('about_us.php');
break;
default:
include_once('home.php');
break;
endswitch;
endif;
?>