加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 为什么Code Igniter无法检测到我的表单是通过POST提交的

发布时间:2020-12-13 17:18:47 所属栏目:PHP教程 来源:网络整理
导读:我的jQuery Mobile应用程序中的Code Igniter视图中有一个表单. form action="?= BASE_PAGE_URL ?settings" method="post" id="settingsForm" div data-role="fieldcontain" label for="firstName"First Name/label input type="text" name="firstName" id="f
我的jQuery Mobile应用程序中的Code Igniter视图中有一个表单.

<form action="<?= BASE_PAGE_URL ?>settings" method="post" id="settingsForm">
    <div data-role="fieldcontain">
        <label for="firstName">First Name</label>
        <input type="text" name="firstName" id="firstName" value="" placeholder="First Name" />
    </div>
    <div data-role="fieldcontain">
        <label for="lastName">Last Name</label>
        <input type="text" name="lastName" id="lastName" value="" placeholder="Last Name" />
    </div>
    <input type="hidden" name="purpose" value="register" />
    <input type="submit" name="submit" value="Register" />
</form>

但是,当我将此代码写入控制器方法时,操作指定的URL会导致:

echo ($_SERVER['REQUEST_METHOD'] == 'POST') ? "yay" : "nay";

当我点击提交按钮时,“nay”被写入页面.为什么Code Igniter不能告诉我我提交了一个帖子请求?

解决方法

如果要确定是否有POST数据,或者请求是POST,请使用 input class中的post()方法

$this->input->post(index);

//returns FALSE if no POST data
//returns the POST array if there is data (hence,a POST)
//returns a specific data from the array if you provide "index"

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读