首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Joomla2.5获取$_POST

使用Joomla2.5获取$_POST
EN

Stack Overflow用户
提问于 2012-11-22 03:38:07
回答 5查看 13.6K关注 0票数 5

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

代码语言:javascript
复制
    <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>

ControllerHello内幕

代码语言:javascript
复制
    public function create()
    {
       $jinput = JFactory::getApplication()->input;
       $foo = $jinput->get('state', '', 'filter');
       print_r($foo);
       die;
    }

返回"NULL“

有什么想法吗?

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2012-11-23 22:15:17

代码语言:javascript
复制
$input = new JInput;
$name = $input->get('name', '', 'post');
$country = $input->get('country', '', 'post');
// etc.

然后,您可以将一系列JInput类方法用于特定目的:

代码语言:javascript
复制
 // 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)
票数 4
EN

Stack Overflow用户

发布于 2013-03-31 17:14:20

你可以试试这个-

代码语言:javascript
复制
$input = JFactory::getApplication()->input;
$post_array = $input->getArray($_POST);
票数 8
EN

Stack Overflow用户

发布于 2014-09-29 18:00:56

我认为使用JInput获得完整$_POST的最佳选择是

代码语言:javascript
复制
JFactory::getApplication()->input->post->getArray();

如果您想从请求中获取特定的数组(例如,名为'jform‘),那么可以使用

代码语言:javascript
复制
JFactory::getApplication()->input->get('jform', array(), 'ARRAY');
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13500803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档