Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Login_Controller extends CI_Controller {
  5.  
  6. public function index()
  7. {
  8. $this->Login_Model->login_check();
  9. $username = $this->input->post('username');
  10.  
  11. $this->form_validation->set_rules('username', 'Kode Pengguna', 'callback_username_check');
  12. $this->form_validation->set_rules('password', 'Kode Sandi', 'callback_password_check');
  13.  
  14. if ($this->form_validation->run() == FALSE) {
  15. $this->load->view('login');
  16. }
  17. else {
  18. $newdata = $this->Login_Model->get_info($username);
  19. $this->session->set_userdata($newdata);
  20. redirect('beranda');
  21. }
  22. }
  23.  
  24. public function username_check()
  25. {
  26. $username = $this->input->post('username');
  27. $username_check = $this->Login_Model->username_check($username);
  28.  
  29. if ($username_check == 0) {
  30. $this->form_validation->set_message('username_check', '<span class="glyphicon glyphicon-info-sign text-warning"></span> {field} belum terdaftar');
  31. return FALSE;
  32. }
  33. else {
  34. $active_check = $this->Login_Model->active_check($username);
  35. if ($active_check == FALSE) {
  36. $this->form_validation->set_message('username_check', '<span class="glyphicon glyphicon-remove-sign text-danger"></span> {field} tidak mempunyai akses');
  37. return FALSE;
  38. }
  39. else {
  40. return TRUE;
  41. }
  42. }
  43. }
  44.  
  45. public function password_check()
  46. {
  47. $username = $this->input->post('username');
  48. $password = $this->input->post('password');
  49.  
  50. if ($this->username_check() == FALSE) {
  51. $this->form_validation->set_message('password_check', '');
  52. return FALSE;
  53. }
  54. else {
  55. $store = $this->Login_Model->password_check($username);
  56.  
  57. if (password_verify($password, $store)) {
  58. return TRUE;
  59. }
  60. else {
  61. $this->form_validation->set_message('password_check', '<span class="glyphicon glyphicon-remove-sign text-danger"></span> {field} tidak sesuai.');
  62. return FALSE;
  63. }
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement