您是否在 form_validation 之后发布输入值?
Codeigniter 问题:
我刚刚使用 $this->form_validation->set_rules(etc 等) 设置了我的第一个表单,在验证运行正确后,我应该使用 $email = $this->input->; 发布值吗?发布('电子邮件',TRUE);或者表单验证是否已经发布了值?如果是这样 - 我如何返回这些值?
谢谢, 沃克
Codeigniter question:
I've just setup my first form with $this->form_validation->set_rules(etc etc), after the validation runs corrects should I post the values using $email = $this->input->post('email', TRUE); or is did the form validation already post the values? If so - how do I return those values?
Thanks,
walker
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
执行验证后,这些值仍然存在于
$_POST
数组中,因此根据您的应用和您的需求,您可能需要也可能不需要将它们分配给变量。延伸-
如果您要进行进一步处理,那么建议执行
$email = $this->input->post('email');
,但您同样可以通过例如,将整个 $_POST 数组发送到模型,而无需执行任何额外的输入 -$this->my_model->do_something($this->input->post())
当然取决于你的要求。
After your validation is performed, the values still exist in the
$_POST
array, so depending on your app and your needs, you may or may not need to assign them to variables.To extend -
If you are going to do further processing, then it would be advisable to do
$email = $this->input->post('email');
, but you could equally just pass the entire $_POST array to a model, for instance, without having to do any extra typing -$this->my_model->do_something($this->input->post())
Depending on your requirements of course.
input->post 表示 PHP 中 $_POST 超全局数组中的内容。这是在 Codeigniter 对脚本执行任何操作之前设置的 - 这也意味着 Codeigniter 从 $_POST 填充 input->post 。因此,当您“发布”值时,您只需提交一个方法设置为 POST 的表单。有道理吗?
从那里 CI_Controller 类处理其余的事情,并且您应该能够在验证之前、期间或之后的任何时间访问 input->post 。
input->post means whatever is in the $_POST superglobal array in PHP. This is set before Codeigniter does anything with your script - and it also means Codeigniter populates input->post from $_POST. So when you "post" values, you're simply submitting a form with the method set to POST. Make sense?
From there the CI_Controller class handles the rest, and you should be able to access input->post at any time before, during or after validation.
是的你是对的。
您希望使用以下语法检索发布值:
处理表单中更新数据的一种简单方法是:
Yes -- you are right.
Yout want to retrieve post values with the following syntax:
An easy way to handle update data from a form would be: