Welcome Guest, Not a member yet? Register   Sign In
My form validation wont work
#1

hi, am new to codeigniter and am currently using it to develop a web app for a bus ticket system as a school project. Am currently facing a serious issue with my registration form using the form validation and i need help. Dont know what i did wrong but here is the code:

Controller: register.php
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Register extends CI_Controller {

            public function __construct()
       {
               parent::__construct();
               $this->load->model('model_user');
       
       }

    public function index()
    {
        $data['title'] ='Register';

        $this->load->view('templates/header', $data);
        // $this->load->view('templates/navigation');
        $this->load->view('frontend/view_register');
        $this->load->view('templates/footer');
    }

    public function register_user()
    {
        $this->load->library('form_validation');
        //$this->form_validation->set_error_delimiters('<div class="alert alert-danger" role="alert"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><span class="sr-only">Error:</span>', '</div>');
         $data['title'] = 'Register';



        $this->form_validation->set_rules('firstname', 'First name', 'required|min_length[3]|max_length[15]');
        $this->form_validation->set_rules('lastname', 'Last name', 'required|min_length[3]|max_length[15]');
        $this->form_validation->set_rules('username', 'Username', 'required|min_length[6]|max_length[15]|is_unique[user.username]');
        $this->form_validation->set_rules('email', 'Email', 'required|min_length[6]|max_length[30]|valid_email|is_unique[user.email]');
        $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]|max_length[20]|matches[password_conf]');
        $this->form_validation->set_rules('password_conf', 'Confirm Password', 'required|min_length[6]|max_length[20]');

        if ( $this->form_validation->run() === FALSE) {

            $this->load->view('templates/header', $data);
            // $this->load->view('templates/navigation');
            $this->load->view('frontend/view_register');
            $this->load->view('templates/footer');

        }
        else
        {
            
             $this->model_user->insert_user();

            $this->load->view('templates/header');
            //$this->load->view('templates/navigation');
            $this->load->view('frontend/view_register_success');
            $this->load->view('templates/footer');

        }
        
    }
}

the rest of the codes are attached to this post. Kindly go through and help me out
Reply


Messages In This Thread
My form validation wont work - by koficypher - 04-10-2016, 04:24 AM
RE: My form validation wont work - by PaulD - 04-10-2016, 09:13 AM
RE: My form validation wont work - by koficypher - 04-10-2016, 11:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB