Welcome Guest, Not a member yet? Register   Sign In
Beginner gets some problem
#4

[eluser]mikeymayhem[/eluser]
Think you should have a good read of the user guide about form validation but heres a step in the right direction. hope it helps you along the way

Controller
Code:
<?php

class Inloggen extends Controller {

    //note your class names shoudl start with an uppcase CHAR ie In
    function Inloggen() {
        parent::Controller();
        //maybe think about autoloading these helpers
        $this->load->helper(array('form', 'url'));

        $this->load->library('form_validation');
    }

    function index() {
        $this->load->view('login');
    }

    function post() {
        //not sure what your intention is here
        $this->input->post('gebruiker');
        $this->input->post('password');
    }

    function valideer() {
        //you can save your validation rules one of two ways,
        //as a config file called form_validation (see user guide)
        //or by setting them individually in your controller. like so....
        //the names specified in the rules should relate to the name fields of your
        // form inputs
        $this->form_valdiation->set_rules('username', 'Username', 'required|max_length[12]|min_length[5]');
        $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == FALSE) {
            //if the form validation returns false, ie has errors reload the view
            //so we can display the errors
            $this->load->view('login');
        } else {
            //validate user login details against the db or something here
        }
    }

}


Messages In This Thread
Beginner gets some problem - by El Forum - 10-09-2010, 02:45 PM
Beginner gets some problem - by El Forum - 10-09-2010, 10:56 PM
Beginner gets some problem - by El Forum - 10-10-2010, 05:09 AM
Beginner gets some problem - by El Forum - 10-10-2010, 07:12 AM
Beginner gets some problem - by El Forum - 10-10-2010, 09:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB