![]() |
how to using session in library...please help me... - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how to using session in library...please help me... (/showthread.php?tid=17915) |
how to using session in library...please help me... - El Forum - 04-20-2009 [eluser]Unknown[/eluser] i was creating a web site for my school and for the login menu i have make like this: model: <?php class Login_m extends Model { function __construct() { } function login($ID, $password) { $this->db->where('ID_user', $ID); $this->db->where('password', $password); $dat = $this->db->get('user'); if($dat->num_rows() > 0) { return 'OK'; } else { return 'FAILED'; } } } controller: <?php class login_c extends Controller { function __construct() { parent::controller(); } function index() { $this->load->view('public\login'); } function login_process() { $ID = $this->input->post('ID'); $password = $this->input->post('password'); $this->load->model('login_m'); if($this->login_m->login($ID, $password)== 'OK') { echo $this->load->view('public\siswa'); } else { echo $this->load->view('public\login2'); } } function _success() { $this->load->view('public\home_view'); } } ?> and now i can't develop my project bcoz i dont know to complete the login menu i have created table user with field : ID_user, Name_user, Level, password... user access with their level, if level 1 for admin, level 2 for teacher, level 3 for the student..and if the login is failed the page will showing error message "login failed" what the code so i can login with the level i was created, and every page for every user just can access if the user was login(restrict page)... please give me the source code for controller and the model, and if there are any change in the library please explain for me about it..and what can i do with every page from every user.. thanks.... how to using session in library...please help me... - El Forum - 04-20-2009 [eluser]Dam1an[/eluser] Firtly, you shoould always use code blocks when you have more then one or two lines of code, I had to paste it in my IDE to be able to easily read your code Here's some quick code I knocked up Make sure you autoload session and database Model: Code: <?php Controller: Code: <?php As for only letting you view pages you have the access level to view, just put a check like Code: if($this->session->userdata('level') == 1) { |