$ this-> input-> post()未按预期工作

时间:2017-01-21 16:27:05

标签: php arrays codeigniter activerecord

这是我的HTML

<input type="text" class="form-control" name="email" placeholder="<?php echo lang('email'); ?>" value="<?php echo $this->input->post('email') ? set_value('email') : $profile['email']; ?>"> 

当我提交表单然后控制器处理数据如

$user = array(
            'email' => trim($this->input->post('email', TRUE)),
            'username' => trim($this->input->post('username', TRUE)),
            'password' => md5($this->input->post('password', TRUE)),
            'email' => trim($this->input->post('mobile', TRUE))
   );

现在var_dump(trim($this->input->post('email', TRUE)));return;此输出为(var_dump()result)

string 'rejoan.er@gmail.com' (length=19)

但是数组不能与SAME DATA一起使用SAME FORM。当var_dump($user)然后email字段数据未收到时。它显示如下

array (size=3)
  'email' => string '' (length=0)
  'username' => string 'rejoan' (length=6)
  'password' => string 'd41d8cd98f00b204e9800998ecf8427e' (length=32)

我在这里做错了什么???

1 个答案:

答案 0 :(得分:1)

上的小错误
$user = array(
    'email' => trim($this->input->post('email', TRUE)),
    'username' => trim($this->input->post('username', TRUE)),
    'password' => md5($this->input->post('password', TRUE)),
    'email' => trim($this->input->post('mobile', TRUE)) <==== Error is in here
);

将第二个'email'更改为'mobile'