1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

class Rejestracja extends Controller {

	function Rejestracja()
	{
		parent::Controller();
	}
	
	function index()
	{
		$this->load->view('rejestracja');
	}
        
        function dodanie_usera()
        {
                $log = $this->db->get('users');
                
                $rules['login'] = "trim|required|min_length[5]|max_length[12]|xss_clean|callback_username_check";
                $rules['password'] = "trim|required|md5";
                $rules['e-mail'] = "trim|required|valid_email";
		
		$this->validation->set_rules($rules);
			
		if ($this->validation->run() == FALSE)
		{
			$this->load->view('rejestracja');
		}
		else
		{
                        $this->db->insert('users', $_POST);
                        $data['thanks'] = "Dziękujemy za rejestrację ;)";
                        $this->load->view('rejestracja_end', $data);
		}
                
                
                
        }
        
        function username_check($str)
	{
                $user = $this->db->get('users');
                
		if ($str == $user['login'])
		{
			$this->validation->set_message('username_check', 'The %s field can not be the word "test"');
			return FALSE;
		}
		else
		{
			return TRUE;
		}
	}
	
}


?>