我的問題似乎與On submit the form don't display its POST data和相關問題類似,但建議的解決方案不適用於我的項目,所以我目前不使用重定向。Zend Framework - 提交不包含發佈數據
我正在嘗試學習Zend Framework。我正在處理的當前項目遇到了從我的表單傳遞的$ _POST和$ _GET超全局變量返回空的問題。我一直致力於簡化問題以確定問題的起因,但我似乎碰到了一堵磚牆。似乎沒有POST數據在所有被髮送...
筆者認爲:
<form method="post" action="/character/addsubmit">
<input type=hidden name='test' id='test' value='test'>
<input type='submit'>
</form>
我的控制器:
<?php
class CharacterController extends Zend_Controller_Action
{
public function addsubmitAction()
{
Zend_Debug::dump($this->getRequest());
echo "<br/>\$_POST: <br/>";
print_r($_POST);
echo "<br/>\$_GET: <br/>";
print_r($_GET);
echo "<br/><br/>";
if($this->_request->isPost()) {
echo "\$_POST Found<br/>";
}
else {
echo "\$_POST Not Found <br/>";
}
if ($this->_request->isGet()) {
echo "\$_GET Found<br/>";
}
else {
echo "\$_GET Not Found<br/>";
}
}
}
?>
導航到表單,然後提交(點擊提交按鈕),我收到以下輸出:
object(Zend_Controller_Request_Http)#8 (15) {
["_paramSources:protected"] => array(2) {
[0] => string(4) "_GET"
[1] => string(5) "_POST"
}
["_requestUri:protected"] => string(20) "/character/addsubmit"
["_baseUrl:protected"] => string(0) ""
["_basePath:protected"] => NULL
["_pathInfo:protected"] => string(20) "/character/addsubmit"
["_params:protected"] => array(3) {
["controller"] => string(9) "character"
["action"] => string(9) "addsubmit"
["module"] => string(7) "default"
}
["_rawBody:protected"] => NULL
["_aliases:protected"] => array(0) {
}
["_dispatched:protected"] => bool(true)
["_module:protected"] => string(7) "default"
["_moduleKey:protected"] => string(6) "module"
["_controller:protected"] => string(9) "character"
["_controllerKey:protected"] => string(10) "controller"
["_action:protected"] => string(9) "addsubmit"
["_actionKey:protected"] => string(6) "action"
}
$_POST:
Array ()
$_GET:
Array ()
$_POST Not Found
$_GET Found
有一件事真的讓我失望op是isGet函數返回true ..
有沒有人有更多的Zend知識有任何想法,爲什麼我有這麼多的麻煩提交表單與此框架?是否有一些配置可能會導致錯誤或可能設置錯誤?
注:我正在使用Zend_Form實際應用程序,以及使用更多的框架本身,但我試圖調試此問題已縮小它。如果您需要關於我的配置的更多信息,我將能夠提供。
謝謝!
編輯:
我的.htaccess文件的內容:
[因爲這是錯誤的文件我已經刪除了這些行, 我仍然在尋找正確的。]
安置自己的'.htaccess'文件的內容(如果使用Apache) – Phil 2011-05-26 06:04:57
你能提供真實生產這種形式Zend_Form類? – 2011-05-26 09:22:29
@Phil我正在使用GoDaddy主機(是的,我知道,不是最好的,但它是我有的,我會看到我能爲你找到的東西 – VOIDHand 2011-05-26 12:50:30