Domain Discussion Board

Go Back   Domain Discussion Board > General > Tutorials

 
Reply
 
LinkBack Thread Tools Display Modes
PHP .php?id= Function
Old
  (#1 (permalink))
xVizon
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
PHP .php?id= Function - 09-18-2006, 04:58 PM

Most people that are new to php always ask me "how do you mask .php files with any tag you want, the most common w/e.php?id=122323"

basically all this script does is mask the other php files like news.php and will change it to index.php?id=news, so instead of having http://www.yourdomain.com/news.php you would have http:/www.yourdomain.com/index.php?id=news
http:/www.yourdomain.com/index.php?id=forums
http:/www.yourdomain.com/index.php?id=index
and so on and so fourth

well in this im going to show you how to do this :

First of all open up your favorite php coder or editor program "I recommend Dreamweaver, just cause its the best program ever"

Next make a new PHP file, click on the code area and type the following code

Code:
 
<?php
 
/* verify the validity of GET var page
if not set, do a default case */
if(isset($HTTP_GET_VARS['id']))
{
$p = $HTTP_GET_VARS['id'];
}
else
{
$p = 'index';
}
 
switch($p)
{
case 'index':
require('index.php.php');
break;
 
case 'news':
require('news.php');
break;
 
case 'what you want':
require('the file you want.php');
break;
 
default:
exit('Wrong parameter for file inclusion');
}
 
?>
with this code you can add it to any PHP script and it wil mask your urls to .php?id=whateverthefilenameis

use this code in any php file and when you go to put links in a menu like index.php and forums.php and news.php you dont need to do that now just type index.php?id=index or index.php?id=forums, so this makes it easy for viewers as well cause they wont have to remember all the page names just the id= tag :

to change it to say something else instead of ?id= do the following

Code:
 
if(isset($HTTP_GET_VARS['TYPE WHATEVRE YOU WANT HERE']))
{
$p = $HTTP_GET_VARS['TYPE THE EXACT SAME THING AS ABOVE'];
there pretty simple, eh?

Last edited by mtorregiani : 09-20-2006 at 10:53 AM.
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#2 (permalink))
jaime
jaime is an unknown quantity at this point
 
jaime's Avatar
 
Status: Offline
Posts: 1,722
Points: 26.7
Bank: 6,181.5
Total Points: 6,208.2
Donate
Join Date: May 2006
Location: In your mind
Rep Power: 0
Re: PHP .php?id= Function - 09-18-2006, 10:35 PM

[SIZE=2]a question, this is for hide the .php extension????[/SIZE]
   

Reply With Quote
Sponsored Links
Re: PHP .php?id= Function
Old
  (#3 (permalink))
xVizon
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-19-2006, 03:31 AM

No its to mask the /news.php /forums.php whtever.php/ and change it to just the index.php so it will respond to the command index.php?id=news or w/e
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#4 (permalink))
windrider
windrider will become famous soon enough
 
windrider's Avatar
 
Status: Offline
Posts: 1,269
Points: 607.7
Bank: 7,727.0
Total Points: 8,334.7
Donate
Join Date: Jun 2006
Location: Chennai, India
Rep Power: 4
Re: PHP .php?id= Function - 09-19-2006, 08:09 AM

Very interesting. But search engine optimisation is what everyone is raving about these days, and I think it's better to leave the filenames wth the .php extension. I'm just guessing...
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#5 (permalink))
xVizon
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-19-2006, 08:40 AM

if you redirect the link on your menu to index.php?id= the search engine will read that and not crawl the forums.php menu.php files unless they are listed in your text or urls
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#6 (permalink))
jaime
jaime is an unknown quantity at this point
 
jaime's Avatar
 
Status: Offline
Posts: 1,722
Points: 26.7
Bank: 6,181.5
Total Points: 6,208.2
Donate
Join Date: May 2006
Location: In your mind
Rep Power: 0
Re: PHP .php?id= Function - 09-19-2006, 05:26 PM

the search engine only read index.php?id=myid?????? or only read index.php and the another pages not...
   

Reply With Quote
Re: PHP .php?id= Function
Old
  (#7 (permalink))
Argie
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-20-2006, 07:57 AM

Quote:
Originally Posted by xVizon
if you redirect the link on your menu to index.php?id= the search engine will read that and not crawl the forums.php menu.php files unless they are listed in your text or urls
Actually, yes, this is true. A search engine indexed every page on my site except for those that involved using a very similiar method (using include and name of the php file involved). However, I know there is a work around involving the .htaccess file that can allow you to have both Search Engine Optimization and this method.
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#8 (permalink))
xVizon
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-20-2006, 11:40 AM

A search engine doesnt crawl every page on your site if its not listed in a link navigation with href= or not listed on any text what so ever this search engine does not have permission to crawl your websites directory it, looks for works and quotes in texts like the page description and the menu links or affilate links if you have a page called news.php but that is not listed ANYWERE on your site the search engine crawler will not detect it but if index.php?id=news is listed thats what it will detect and only that
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#9 (permalink))
bbalegere
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-20-2006, 10:05 PM

A helpful discussion.Thanks a lot.
   
Reply With Quote
Re: PHP .php?id= Function
Old
  (#10 (permalink))
xVizon
 
Status:
Posts: n/a
Points: 0
Bank: 0
Total Points: 0
Donate
Re: PHP .php?id= Function - 09-21-2006, 11:17 AM

haha no problem man.........!
   
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.0
Points Per Thread: 15.0
Points Per Reply: 5.0


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paginas de host gratis(listado) joseermejo Hosting 23 11-07-2008 01:00 PM
PHP tut 2 - Refining the simple form - using cookies holypanl Scripts 10 05-08-2007 09:39 AM
PHP: A simple form holypanl Scripts 5 04-05-2007 11:33 AM
Codigo Php:Formulario de contacto php y msql javitor52x Tecnologia Web General 7 06-09-2006 10:45 AM


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 ©2007, Crawlability, Inc.