Currently developing a website and am wondering how to include pages into the main index (to only change a certain areas content and not the whole page) using the $_Get function.
Files would be something like index.php (where content pages are included), news.php (default page display on index), members.php, about.php, guides.php, downloads.php, sponsors.php etc.
I believe (if i remember correctly) linking with the $_Get method usually looks something like this index.php?pid=about
I would also like to find out how I can change the link (via htaccess?) to link as follows: http://www.mywebsite.com/about/ instead of mywebsite.com/index.php?pid=about
It has been some time since I have done any PHP and do not remember how the above things are done exactly.
Preview of what I am working on can be found at http://www.survivaloperations.net/dev/
You would put all of your files in a pages folder, just reugular .php files.
your index.php would look like this:
And so your files would look like:
and you would go to:
respectively
You would also want to have control over which $_GET values are allowed. I reccomend using a php switch:
The switch requires less code than a bunch of else if statements, and allows for a default “404”-type page to be displayed when an invalid pid is entered. It also secures users from accessing anything they shouldn’t… like “../db.php” or something (not sure if parent directory access is possible, but still).