|
@@ -0,0 +1,21 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+class FormHandler implements IHandler
|
|
|
|
|
+{
|
|
|
|
|
+ public function execute(Action $action)
|
|
|
|
|
+ {
|
|
|
|
|
+ $pageData = array();
|
|
|
|
|
+ if ($action->method === "POST")
|
|
|
|
|
+ {
|
|
|
|
|
+ $pageData["name"] = "<pre>" . json_encode($_POST) . "</pre>";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $page = new Page("form");
|
|
|
|
|
+ $page->title = "A Form with a Handler";
|
|
|
|
|
+ $page->render($pageData);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+Router::register(new HandlerAction("/form2", "GET", new FormHandler()));
|
|
|
|
|
+
|
|
|
|
|
+Router::register(new HandlerAction("/form2", "POST", new FormHandler()));
|