Code: Select all
class FormHandler
{
public function __construct()
{
$this->query = !empty($_GET['q']) ? $_GET['q'] : 'home';
$this->action = !empty($_GET['a']) ? $_GET['a'] : 'default';
$this->id = !empty($_GET['id']) ? $_GET['id'] : '';
}
// Check for $_POST values
public function IsPost()
{
if (isset($_POST['submit']) != FALSE)
{
$this->ChooseMethod($this->query, $this->action, $this->id);
}
}
// Have the class find and use the appropriate method
private function ChooseMethod($q, $a, $id = NULL)
{
$class_name = sprintf("%s", $q);
$class = new $class_name;
$method_name = sprintf("%s%s", $a, $q);
$class->$method_name();
}
}This is a really early, early version that I just wrote today.
I'll take any and all suggestions