简体   繁体   English

表单提交重定向到codeigniter的索引页

[英]form submit redirecting to index page of codeigniter

When clicking my submit button of the form the page is redirecting to the index page ie the welcome message of codigniter. 单击表单的我的提交按钮时,页面将重定向到索引页面,即codigniter的欢迎消息。 but the url shows the requested page. 但网址显示所请求的页面。 . I m confused. 我糊涂了。

view page: 查看页面:

<form action='welcome/register' method='post'>
<table>......
......
</form>

and in controller page i ve done the validation and if validation fails it have to redirect to register_new page but the redirected page is the welcome page of codeignitor. 在控制器页面中,我已经完成了验证,如果验证失败,则必须重定向到register_new页面,但重定向的页面是codeignitor的欢迎页面。 . But no problem with the url. 但网址没有问题。

This is how you use forms in CodeIgniter. 这就是您在CodeIgniter中使用表单的方式。 Don't try to use HTML forms like that, just use CodeIgniter style 不要尝试使用这样的HTML表单,只需使用CodeIgniter样式

http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html

Add this to your controller (to load the form helper): 将此添加到您的控制器(以加载表单助手):

$this->load->helper('form');

In your view 在您看来

<?php echo form_open('controllername/functionname');?>
     <input type ...>
     //...more inputs
</form>

It redirects to the original page if action is not specified. 如果未指定操作,它将重定向到原始页面。 It shouldn't redirect to the index page ever unless specified by second controller. 除非由第二个控制器指定,否则它不应重定向到索引页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM