开发者

Zend Framework - Submit contains no Post Data

My issue seems similiar to On submit the form don't display its POST data and related questions, but the suggested solutions do not apply to my project, so I am currently not using redirects.

I am attempting to learn Zend Framework. The current project that I am working on has run into an issue where the the $_POST and $_GET superglobals passed from my form are returning empty. I have worked to simplify the issue to identify where it is being caused, but I seem to have hit a brick wall. It seems that no POST data is being sent at all...

My View:

<form method="post" action="/character/addsubmit">
    <input type=hidden name='test' id='test' value='test'>
    <input type='submit'>
</form>

My controller:

<?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/>";
            }
        }
    }
?>

By Navigating to the form, then submitting (by clicking on the submit button), I receive the following output:

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

The one thing that's really throwing me for a loop is that the isGet function is returning true..

Does anyone with more knowledge of Zend have any idea of why I'm having so much trouble submitting forms with this framework? Is there some configuration that I might have missed or may have set incorrectly that might cause this?

Note: I am using Zend_Form for the actually application, as well as using more of the framework itself开发者_Go百科, but I have scaled it back in attempting to debug this issue. If you need any further information about my configuration, I will be able to provide it.

Thanks!

Edit:

My .htaccess file's contents:

[I have removed these lines because it was the wrong file, I am still looking for the correct one.]


This thread is old, but the following tip may help other readers. I have just experienced this problem, and found the solution here:

https://serverfault.com/questions/127674/mysteriously-empty-post-array

I had just set up a local LAMP development environment, and in populating my database via phpMyAdmin, changed the post_max_size directive of php.ini to permit the upload of a large SQL dump. Regrettably, I mistyped 1G as 1GB in the INI file. PHP interpreted this as a 1 byte limit, which naturally all of my POST submissions exceed, thus they were arriving as empty arrays.

Check your server's error log for something resembling the following:

[Sat Oct 01 17:08:07 2011] [error] [client 127.0.0.1] PHP Warning:  Unknown: POST Content-Length of 63 bytes exceeds the limit of 1 bytes in Unknown on line 0, referer: http://localhost/[...]


Have you tried

$this->_request->getParams();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜