PhotoshopStar Forums  

Go Back   PhotoshopStar Forums > Web Development > PHP & MySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2008, 09:41 PM
Seich's Avatar
Seich Seich is offline
Junior
 
Join Date: Jan 2008
Location: Paradise city
Posts: 8
Default picking up webpages with a ?id=

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
PHP Code:
//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!
__________________
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 04:38 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.