question about "?id=123" lookup

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hotmonkey
Forum Newbie
Posts: 2
Joined: Thu Jun 29, 2006 9:42 pm

question about "?id=123" lookup

Post by hotmonkey »

I am sure that someone smarter than me knows this answer.

I am setting up a simple database with 4-5 fields, and wish to use the url to access the db and then redirect the visitor to the proper page. With that said, this url is not a link, it will be typed in, so my question is:

If I create an index page in php that is only looking for one data bit like "12345" eg. .com/pn/index.php?pn=12345. Can I eliminate most of this url down to something like .com/pn/?=12345 or .com/pn/?12345 and still have it work? I am trying to make the url information so simple that when it is on a piece of paper it is as simple as possible and when it is typed in, it works. I don't wish to have a lookup, just a url that is as simple as possible and works, and if so, is there anything special I should be looking for, or avoiding on the processing side. Like assigning an id to the input or limiting the string to five numbers for safety...

Obviously, I am a bit new to this part of the process, but I'm a fast learner.

So is there anyone that might be able to offer a bit of insight to this, it will be most welcome.

Thank you...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

You can use mod_rewrite and have URLs like:

http://www.mydomain.com/pn/12345

Or use $_SERVER['PATH_INFO'] have URLs like:

http://www.mydomain.com/mypage.php/pn/12345

but the other URLs you showed will not work.
(#10850)
hotmonkey
Forum Newbie
Posts: 2
Joined: Thu Jun 29, 2006 9:42 pm

Post by hotmonkey »

Regretfully, I do not have access to mod_rewrite or httpd.conf, so I seem forced to use the url.

I think I have seen shorter urls in some blogs and such and don't think they are using mod_rewrite, like http://www.website.com/blog/?p=173. Do these require something special that I am missing. I just don't know enough to move ahead and make this work... any tutorials or something?

Thank you...
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

If the page name is not given then the default page will be used. For Apache, that is ususally index.php.
(#10850)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Arborint's right. Whatever folder you are in when sending the server a request like that will use the default page for the server setup. In Apache, it is usually index.<prioritized_extension> where the extension is configured into your httpd.conf. If you are on a hosted server that supports PHP, then more than likely you will be able to set up a page called index.php and call it from the URI like you want.

Please take note that passing information from the URI to the script for the purposes of data extraction is risky business. If there is another, safer way for you to do this, you may want to consider it.
Post Reply