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.

    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?