Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Post表单只接受一个字符——PHP CodeIgniter MVC_Php_Forms_Codeigniter - Fatal编程技术网

PHP Post表单只接受一个字符——PHP CodeIgniter MVC

PHP Post表单只接受一个字符——PHP CodeIgniter MVC,php,forms,codeigniter,Php,Forms,Codeigniter,我希望我的代码能有另一双眼睛,因为我不明白为什么我的post数据只接受输入字段的第一个字符 以下是我的看法: <form id="SearchTerm" accept-charset="utf-8" method="post" action="<?php echo site_url("record/search/"); ?>"> <input name="SearchTerm" type="text"> | <input type="submit

我希望我的代码能有另一双眼睛,因为我不明白为什么我的post数据只接受输入字段的第一个字符

以下是我的看法:

<form id="SearchTerm" accept-charset="utf-8" method="post" action="<?php echo site_url("record/search/"); ?>">
    <input name="SearchTerm" type="text"> | <input type="submit">
  </form>
当我转储$SearchTerm时,只捕获输入字段的第一个字符。 你们专业的程序员有什么建议吗


提前谢谢你

$p_data=$this->input->post('SearchTerm')
获取
$\u POST['SearchTerm']
的值。所以调用
$SearchTerm=$p_data['SearchTerm']是不必要的,可能是导致问题的原因

$p_data = $this->input->post('SearchTerm');
if(!$p_data) {
    $SearchTerm = '0';
}

但是最后一个if语句可能也没有必要,因为如果
$$this->input->post('SearchTerm')
为空,那么
$\u post['SearchTerm']
将返回false。

我认为$p\u data=$this->input->post('SearchTerm');返回一个布尔值,因此,我使用它检查表单是否首先提交。关于这一点我是不是错了?这将返回POST变量的值,如果它不存在,则返回false。更多信息,请参阅。谢谢大家的帮助!很好!但愿我能多注意那些文档。$SearchTerm=$p_数据['SearchTerm'];可能应该是$SearchTerm=$p_数据;
$p_data = $this->input->post('SearchTerm');
if(!$p_data) {
    $SearchTerm = '0';
}