Php 使用Joomla 2.5获得$\邮政

Php 使用Joomla 2.5获得$\邮政,php,html,forms,post,joomla,Php,Html,Forms,Post,Joomla,这是我的表单,它看起来正确,所以这不应该是个问题,我也删除了enctype以确保它不是那样 <form action="<?php echo JRoute::_('index.php?option=com_woo&task=hello.create'); ?>" enctype="multipart/form-data" method="post"> <p> Project Name : <i

这是我的表单,它看起来正确,所以这不应该是个问题,我也删除了enctype以确保它不是那样

    <form action="<?php echo JRoute::_('index.php?option=com_woo&task=hello.create'); ?>" enctype="multipart/form-data" method="post">
      <p>
        Project Name : 
        <input style="width:30%;" name="name" id="name"/>
        <input style="display:none;" id="user_id" name="user_id" value="<?php echo $user->id;?>"/>
        <input style="display:none;" id="county" name="county"/>
        <input style="display:none;" id="state" name="state"  />
      </p>
      <button type="submit" class="btn-green" id="select_county">Create Project</button>
    </form>
返回“NULL”


有什么想法吗?

您可以尝试将表单操作更改为:

<?php echo JRoute::_('index.php?option=com_woo&view=hello&task=create');
然后,您可以出于特定目的使用一系列JInput类方法:

 // method      integer  getInt()       getInt($name, $default = null)    Get a signed integer.
 // method      integer  getUint()      getUint($name, $default = null)   Get an unsigned integer.
 // method      float    getFloat()     getFloat($name, $default = null)  Get a floating-point number.
 // method      boolean  getBool()      getBool($name, $default = null)   Get a boolean.
 // method      string   getWord()      getWord($name, $default = null)
 // method      string   getAlnum()     getAlnum($name, $default = null)
 // method      string   getCmd()       getCmd($name, $default = null)
 // method      string   getBase64()    getBase64($name, $default = null)
 // method      string   getString()    getString($name, $default = null)
 // method      string   getHtml()      getHtml($name, $default = null)
 // method      string   getPath()      getPath($name, $default = null)
 // method      string   getUsername()  getUsername($name, $default = null)
你可以试试这个-

$input = JFactory::getApplication()->input;
$post_array = $input->getArray($_POST);

我认为用JInput获得整个$u帖子的最佳选择是

JFactory::getApplication()->input->post->getArray();
如果要从请求中获取特定数组(例如称为“jform”),请使用

JFactory::getApplication()->input->get('jform', array(), 'ARRAY');

您可以从特定的超全局变量获取值

$foo = $jinput->get->get('varname', 'default_value', 'filter');

$foo = $jinput->post->get('varname', 'default_value', 'filter');

$foo = $jinput->server->get('varname', 'default_value', 'filter');

有关更多信息,请转到JRequest,JRequest从Joomla 1.7开始就已弃用。这并不是说你错了,但最好是使用以下内容:
$post=newjinput($\u post)适用于Joomla 2.5及以后版本;)房客是正确的。在这里查看更多关于JInput的信息,根据您的输入字段<代码>状态>代码>已设置为<代码>显示:没有“< /代码>”,每当表单提交时,它将空白输入发送到状态>代码>,这就是为什么您获得了 null >代码>而不是值的原因。
JFactory::getApplication()->input->post->getArray();
JFactory::getApplication()->input->get('jform', array(), 'ARRAY');
$foo = $jinput->get->get('varname', 'default_value', 'filter');

$foo = $jinput->post->get('varname', 'default_value', 'filter');

$foo = $jinput->server->get('varname', 'default_value', 'filter');