6 changed files with 176 additions and 3 deletions
			
			
		@ -0,0 +1,39 @@ | 
				
			|||||||
 | 
					<?php | 
				
			||||||
 | 
					defined('BASEPATH') OR exit('No direct script access allowed'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					* Add regio table | 
				
			||||||
 | 
					*/ | 
				
			||||||
 | 
					class Migration_Add_regio extends CI_Migration | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function up() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							$this->dbforge->add_field(array( | 
				
			||||||
 | 
								'id' => array( | 
				
			||||||
 | 
									'type' => 'INT', | 
				
			||||||
 | 
									'constraint' => '3', | 
				
			||||||
 | 
									'unsigned' => TRUE, | 
				
			||||||
 | 
									'auto_increment' => TRUE, | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
								'naam' => array( | 
				
			||||||
 | 
									'type' => 'VARCHAR', | 
				
			||||||
 | 
									'constraint' => '80', | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
							)); | 
				
			||||||
 | 
							$this->dbforge->add_key('id', TRUE); | 
				
			||||||
 | 
							$this->dbforge->create_table('regio'); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							$data = array( | 
				
			||||||
 | 
							        'id' => '0', | 
				
			||||||
 | 
							        'naam' => 'LSW' | 
				
			||||||
 | 
							); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							$this->db->insert('regio', $data); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function	down() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							$this->dbforge->drop_table('regio'); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,42 @@ | 
				
			|||||||
 | 
					<?php | 
				
			||||||
 | 
					defined('BASEPATH') OR exit('No direct script access allowed'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					* Add regio table | 
				
			||||||
 | 
					*/ | 
				
			||||||
 | 
					class Migration_Add_user extends CI_Migration | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function up() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							$this->dbforge->add_field(array( | 
				
			||||||
 | 
								'id' => array( | 
				
			||||||
 | 
									'type' => 'INT', | 
				
			||||||
 | 
									'constraint' => '4', | 
				
			||||||
 | 
									'unsigned' => TRUE, | 
				
			||||||
 | 
									'auto_increment' => TRUE, | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
								'regioid' => array( | 
				
			||||||
 | 
									'type' => 'INT', | 
				
			||||||
 | 
									'constraint' => '3', | 
				
			||||||
 | 
									'unsigned' => TRUE, | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
								'username' => array( | 
				
			||||||
 | 
									'type' => 'VARCHAR', | 
				
			||||||
 | 
									'constraint' => '80', | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
								'password' => array( | 
				
			||||||
 | 
									'type' => 'VARCHAR', | 
				
			||||||
 | 
									'constraint' => '80', | 
				
			||||||
 | 
								), | 
				
			||||||
 | 
							)); | 
				
			||||||
 | 
							$this->dbforge->add_key('id', TRUE); | 
				
			||||||
 | 
							$this->dbforge->create_table('user'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function	down() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							$this->dbforge->drop_table('user'); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,42 @@ | 
				
			|||||||
 | 
					<?php | 
				
			||||||
 | 
					defined('BASEPATH') OR exit('No direct script access allowed'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					* Regio model | 
				
			||||||
 | 
					*/ | 
				
			||||||
 | 
					class Login_model extends CI_Model | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function __construct() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							parent::__construct(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function check_user() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							// Validate POST | 
				
			||||||
 | 
							$username = $this->security->xss_clean($this->input->post('username')); | 
				
			||||||
 | 
							$password = $this->security->xss_clean($this->input->post('password')); | 
				
			||||||
 | 
							$regioid = $this->security->xss_clean($this->input->post('regioid')); | 
				
			||||||
 | 
							//$username = $this->input->post('username'); | 
				
			||||||
 | 
							//$password = $this->input->post('password'); | 
				
			||||||
 | 
							//$regioid = $this->input->post('regioid'); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							// Search for user | 
				
			||||||
 | 
							$this->db->select('id'); | 
				
			||||||
 | 
							$this->db->where('username', $username); | 
				
			||||||
 | 
							$this->db->where('password', sha1($password)); | 
				
			||||||
 | 
							$this->db->where('regioid', $regioid); | 
				
			||||||
 | 
							$this->db->from('user'); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							$query = $this->db->get(); | 
				
			||||||
 | 
							//echo $query->num_rows(); | 
				
			||||||
 | 
							if ($query->num_rows() == 1) | 
				
			||||||
 | 
							{ | 
				
			||||||
 | 
								return TRUE; | 
				
			||||||
 | 
							} else { | 
				
			||||||
 | 
								return FALSE; | 
				
			||||||
 | 
							} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
@ -0,0 +1,25 @@ | 
				
			|||||||
 | 
					<?php | 
				
			||||||
 | 
					defined('BASEPATH') OR exit('No direct script access allowed'); | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/** | 
				
			||||||
 | 
					* Regio model | 
				
			||||||
 | 
					*/ | 
				
			||||||
 | 
					class Regio_model extends CI_Model | 
				
			||||||
 | 
					{ | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function __construct() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							parent::__construct(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
						 | 
				
			||||||
 | 
						public function get_regio_list() | 
				
			||||||
 | 
						{ | 
				
			||||||
 | 
							$this->db->select('id, naam'); | 
				
			||||||
 | 
							$this->db->from('regio'); | 
				
			||||||
 | 
							$this->db->order_by('naam', 'ASC'); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							$query = $this->db->get(); | 
				
			||||||
 | 
							 | 
				
			||||||
 | 
							return $query->result_array(); | 
				
			||||||
 | 
						} | 
				
			||||||
 | 
					} | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue