在SLIM 2中,我有一個小表單來顯示用戶名。如何在SLIM 2框架中顯示HTTP POST數據
我的index.php
$app = New \SlimController\Slim()
//Define routes
$app->addRoutes(array('/' => array('get' => 'Home:indexGet','post' => 'Home:indexPost'),
));
在postpage.php:
<form action="" method="post">
<input type="text" name="username">
<input type="text" name="password">
<input type="submit">
</form>
這裏是我的控制器功能:
public function indexPostAction()
{
$this->render('postpage');
}
這裏是我的postpage.html
var_dump($app->request->post("username"));
我得到這個錯誤:
異常 'ErrorException' 有消息 '未定義的變量:應用'
我想也嘗試var_dump($this->app->request->post("username"));
,我得到
異常「ErrorException '消息'未定義變量:此'
您可能想澄清哪些版本的Slim使用2.0或3.0,我認爲它們之間存在細微的差異,可能會影響答案。 – Mikey