Seich
01-08-2008, 08:41 PM
Hello every one seich here, have you ever wondered how some sites call a specific page using a url like this www.somedomain.com/index.php?id=mypage
well if you did wonder about that i will show you how to make one in the most basic form possible for me. please fill free to ask if you don't understand something.
ok the file can be name whatever you want like the one above would be named index i will use a file named news.php for the purpose of this example.Please follow the comments.
news.php
//sets up current page and specifies to get info from the url.
if(!isset($_GET['id'])){
$page = "home";
}
//if theres a id string in the url use it for the $id variable.
else {
$id = $_GET['id'];
}
//look for file or return error
if(file_exists("pages/".$id .".php")){
include("pages/".$id .".php");
}
else {
//you can replace this with your own error message or function
echo ('Page not found');
ok you are now almost done after you save the above file make a directory named pages and save all pages you will serve there make sure it has a .php extension.
example:
www.somedomain.com/news.php?id=local
would look for the page local.php in the pages directory
ok we are now done hope you can use this script to help you!;)
well if you did wonder about that i will show you how to make one in the most basic form possible for me. please fill free to ask if you don't understand something.
ok the file can be name whatever you want like the one above would be named index i will use a file named news.php for the purpose of this example.Please follow the comments.
news.php
//sets up current page and specifies to get info from the url.
if(!isset($_GET['id'])){
$page = "home";
}
//if theres a id string in the url use it for the $id variable.
else {
$id = $_GET['id'];
}
//look for file or return error
if(file_exists("pages/".$id .".php")){
include("pages/".$id .".php");
}
else {
//you can replace this with your own error message or function
echo ('Page not found');
ok you are now almost done after you save the above file make a directory named pages and save all pages you will serve there make sure it has a .php extension.
example:
www.somedomain.com/news.php?id=local
would look for the page local.php in the pages directory
ok we are now done hope you can use this script to help you!;)