Forever and ever, since I have been coding websites, I have had one problem that drives me insanely crazy.
The URLs of my website look like this:
http://www.camicus.net/?q=home
http://www.camicus.net/?q=weblog&a=search
http://www.camicus.net/?q=weblog&a=details&id=1
Stop! You are thinking, don't. Just listen.
Forever and ever, whenever I would be writing admin pages, I would POST the form. Now, you can't post to something sexy like a querystring.
You have to post to form_handler.php and then redirect back to a sexy querystring.
I hate that! I hate, hate, hate that! I hate it.
I figured it out today. It was beautiful. PHP Buddha came to me and told me how to right this horrible, horrible wrong.
I have a page, index.php
index.php inits a class named PageBuilder
every form posts to index.php?q=weblog&a=addentry or something other such thing
PageBuilder checks for POST data to index php and then checks the querystring and decideds what functions it needs to call.
Code: Select all
// Gangster pseudo-code
$pagebuilder->buildpage
// buildpage:
function buildpage
{
if ($_POST)
{
// handle the form data
}
// call functions to output page
}I hope this helps someone as stupid as me.
I'll never use header() or meta redirects again.