douweilaton2762 2016-10-27 00:29
浏览 135

在codeigniter中进行表单验证的问题

i have an issue in validinting my form it's a singup form, i have login and user controller, whene i submit the form it takes me to login page.

Whene i change the default controoler to "user" it validates the form but whene i want to login it's not working. i want to know what is the probleme !

this is the validation form code from the user controller :

public function __construct()
    {
        parent::__construct();
        $this->load->helper(array('form','url'));
        $this->load->library(array('session', 'form_validation', 'email'));
        $this->load->database();
        $this->load->model('user_model');
    }
    function index()
        {
            //set validation rules
            $this->form_validation->set_rules('name', 'First Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
            $this->form_validation->set_rules('prenom', 'Last Name', 'trim|required|alpha|min_length[3]|max_length[30]|xss_clean');
            $this->form_validation->set_rules('email', 'Email ID', 'trim|required|valid_email|is_unique[teacher.email]');
            $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[cpassword]|md5');
            $this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required|md5');

            //validate form input
            if ($this->form_validation->run() == FALSE)
            {
                // fails
                $this->load->view('backend/user_registration_view');
            }

this is the view :

<div class="panel-body">
                <?php $attributes = array("name" => "registrationform");
                echo form_open("user/register", $attributes);?>
                <div class="form-group">
                    <label for="name">First Name</label>
                    <input class="form-control" name="name" placeholder="Your First Name" type="text" value="<?php echo set_value('name'); ?>" />
                    <span class="text-danger"><?php echo form_error('fname'); ?></span>
                </div>

this is the ink where i test my app please helpe me solve this issue:

http://prof.skolarie.com (login is the default controller).

I think whene login is set by default override the user controller !

Thanks

Update : The routes file;

$route['default_controller'] = 'login';

$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

You can find the code source in this link below :

http://prof.skolarie.com/uploads/myapp.zip

  • 写回答

2条回答 默认 最新

  • dongye7231 2016-10-27 01:11
    关注

    Your pages are hard to read, try yo have things as simple as you can, so you can see where you made any mistake, i tried to see where the problem could be, but all i can find is that your forms are pointing to strange links ex the registration form is pointing to :

    http://prof.skolarie.com/index.php/user/index
    

    This link is really missed up, the form should be pointing to a controller that checks the inputs, puts them into the database using a model, then point back to the logging controller

    Also it might be either a routing problem, or that you have changed your 404 error view, because visiting any random page on your website, it generates a login form instead of showing a 404 error (ex : i visited : http://prof.skolarie.com/index.php/random/random/random123 and it kept showing me the login form ), make sure your routes are valid, and that they point to the right controller.

    If you keep having this problem, have the right code samples posted, as well as for your routes.

    评论

报告相同问题?

悬赏问题

  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?