Forum Moderators: coopster

Message Too Old, No Replies

verifying includes - checking includes

         

mipapage

3:51 pm on Aug 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me start by saying that I am a PHP rookie.

I have built a few simple sites with PHP using a template and one variable that is an included file. The include usually has 3-5 functions which fill in the necessary bits of the template.

Basically, the url would look like this:
www.mysite.com/template.php?page=home, for example.

To make sure that things aren't abused, I usually take the variable from the url and check it against a list of valid values which are stored in an array. If it passes you get a page, if not you get a 404.

Now I am building what will likely be a larger site - ie. there could be upwards of 150 pages = 150 values that need to be in that array. The array sits at the top of the template, which for a small site (<30 pages) seems fine. But now things may get to the point that 150+ values sitting there in the main template seems to me to be a bit... rookie.

Is there a simple solution to this? And honestly folks, is there an advantage to me using a database to store all of the data vs. a separate 'include.php' for each page? If so, I would imagine that it's hit the books time for me...

vincevincevince

10:08 pm on Aug 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd say ditch the template.php?page=home concept
rename your template.php to 404.php
put in an .htaccess directive that 404.php is the defaulterror document
store all your data in a database
in 404.php parse out the $_SERVER['REQUEST_URI'] for the requested file name, then use to query the database, and return a 200 OK header, then results

now you can:
1 - easily store hundreds, thousands, or more pages in the database
2 - call them using yourdomain.com/home.htm yourdomain.com/faq.htm etc. etc. etc. - without these files ever really existing :-)

mipapage

10:20 pm on Aug 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oookaay. Well, you are the reason that my error page now correctly returns a 404, instead of a '200 error page', so I'll go and try to digest what you just said!

Thanks!