Codeigniter:以html格式显示数据库字段,然后编辑的表单字段在php脚本中不可见

Codeigniter:以html格式显示数据库字段,然后编辑的表单字段在php脚本中不可见

问题描述:

I'm having little problem, I'll try to describe what is it about: at first page I got only form input field (username expected), then on submit I'm proceed to second page where I got form with fields that I've read from database and put them inside input value="xxx". When i retype some of that fields, and submit on next script form parameters are empty($field) == true. Fields are not empty and when I submit they are marked as empty variables.

Here's my code hope it will help:

My second page view (CODE)
My controller's method to take parameters from second page view (CODE)

Here's screenshots maybe it can be helpful:

i.stack.imgur.com/1zx9S.png
i.stack.imgur.com/3UH97.png
i.stack.imgur.com/ipB6Y.png

Anyone got idea why am I getting empty variable when I read them in script?

Thanks in advance

我没有什么问题,我会尝试描述它是什么:在第一页我只得到了 表单输入字段(用户名预期),然后提交我进入第二页,我得到表单,其中包含我从数据库中读取的字段,并将它们放在输入 value =“xxx” code>中。 当我重新键入其中一些字段,并在下一个脚本表单上提交参数时,为空($ field)== true code>。 字段不为空,当我提交时,它们被标记为空变量。 p>

这是我的代码希望它有所帮助: p>

我的第二页视图(CODE)
我的控制器从第二页视图(CODE)获取参数的方法 p> blockquote> 这里的截图可能会有所帮助: strong> p>

i.stack.imgur.com/1zx9S.png
i.stack.imgur.com /3UH97.png
i.stack.imgur.com/ipB6Y.png p>

任何人都知道为什么我在脚本中读取它时会得到空变量? p>

提前致谢 em> p> div>

I'm honestly sorry, I've just realized that in mixing that php and html, I've forgot to add name attribute in html tags.

You should pass a data array to the db. Something like this

    public function submitEditChanges($id){
    $data = array(
                'name' => $this->input->post('name'),
                'surname' => $this->input->post('surname'),
                'city' => $this->input->post('city'),
                'email' => $this->input->post('email'),
                'username' => $this->input->post('username'),
                'password' => sha1($this->input->post('password')),
                'passconf' => sha1($this->input->post('passconf'))
            );
            $this->db->where('id', $id);
            $this->db->update('users',$data);
    }