Welcome Guest, Not a member yet? Register   Sign In
help! validation class doesnt work!
#4

[eluser]Unknown[/eluser]
well, this is my real code:

controllers/register.php
Code:
<?php
class Register extends Controller {

    function Register()
    {
        parent::Controller();
        $this->load->helper("form");
        
    }
    
    function index()
    {
        $view_data = array(
            'title' => 'Register',
            'css' => 'blue.css',
        );
        
        $this->load->library('validation');
    
        $rules['username'] = "required";
        $rules['password'] = "required";
        $rules['password2'] = "required";
        $rules['nickname'] = "required";
        $rules['email'] = "required";

        $this->validation->set_rules($rules);
        if ($this->validation->run() == FALSE)
        {
            $view_data['content'] = 'form'; // print register form
        }
        else
        {
            //insert into database
            //
            
            $view_data['content'] = 'success'; // print success msg
        }
        $this->load->view($this->config->item('template').'/register',$view_data);
    }
}
?>

and this is the error msg:
Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined property: Register::$validation

Filename: controllers/register.php

Line Number: 26


Fatal error: Call to a member function set_rules() on a non-object in F:\ciblog\system\application\controllers\register.php on line 26

this is very strange! i have used print_r($this) after loading the validation library, but i didn't see anything about the validation object


Messages In This Thread
help! validation class doesnt work! - by El Forum - 01-04-2008, 02:30 AM
help! validation class doesnt work! - by El Forum - 01-04-2008, 02:41 AM
help! validation class doesnt work! - by El Forum - 01-04-2008, 02:51 AM
help! validation class doesnt work! - by El Forum - 01-04-2008, 07:00 AM
help! validation class doesnt work! - by El Forum - 01-04-2008, 07:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB