Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. // html login.php view ====================================================
  2.  
  3. <form class="form-horizontal form-material" method="POST" id="loginform" action="<?php echo base_url(); ?>Auth/logincheck">
  4. <h3 class="box-title m-b-20">Sign In</h3> <h4> <font="red"><?php echo $this->session->flashdata('feedback');?></font> <font="red"><?php echo $this->session->flashdata('Recoverysuccess');?></font> <font="red"><?php echo $this->session->flashdata('Recoveryfail');?></font> </h4>
  5. <div class="form-group ">
  6. <div class="col-xs-12">
  7. <input class="form-control" value="<?php echo $this->input->cookie('Username',true); ?>" name="Username" type="text" required="" placeholder="Username">
  8. </div>
  9. </div>
  10. <div class="form-group">
  11. <div class="col-xs-12">
  12. <input class="form-control" value="<?php echo $this->input->cookie('Password',true); ?>" name="password" type="password" required="" placeholder="Password">
  13. </div>
  14. </div>
  15. <div class="form-group">
  16. <div class="col-md-12">
  17. <div class="checkbox checkbox-primary pull-left p-t-0">
  18. <input id="checkbox-signup" <?php if($this->input->cookie('Username',true)!='') {?> checked <?php } ?> type="checkbox" name="Remember">
  19. <label for="checkbox-signup"> Remember me </label>
  20. </div>
  21. <a href="javascript:void(0)" id="to-recover" class="text-dark pull-right"><i class="fa fa-lock m-r-5"></i> Forgot pwd?</a> </div>
  22. </div>
  23. <div class="form-group text-center m-t-20">
  24. <div class="col-xs-12">
  25. <button class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light" type="submit">Log In</button>
  26. </div>
  27. </div>
  28.  
  29. </form>
  30.  
  31.  
  32. // Auth Controller login check function ======================================================================
  33.  
  34. <?php
  35. defined('BASEPATH') OR exit('No direct script access allowed');
  36.  
  37. class Auth extends CI_Controller {
  38.  
  39. public function index()
  40. {
  41. $this->load->view('login');
  42.  
  43. }
  44.  
  45. public function logincheck()
  46. {
  47. //echo "fgf";
  48. $Username=$this->input->post('Username');
  49. $password=$this->input->post('password');
  50. $result=$this->Login_model->Login_check($Username,$password);
  51. //$table='';
  52. //$where=array('is_deleted'=>'N');
  53. //$ordervalue=('id');
  54. //$orderfield=('desc');
  55. //$data['loginresult']=$this->Login_model->Login_check($Username,$password,$table,$where);
  56.  
  57. if($result==1)
  58. {
  59. $type=$this->session->userdata('type');
  60. if($type=='D')
  61. {
  62. redirect('Patient_reception/Patient_doctor','refresh');
  63. }
  64. else
  65. {
  66. //redirect('Dashboard','refresh');
  67. redirect('Patient_reception','refresh');
  68. }
  69. }
  70. else
  71. {
  72. $this->session->set_flashdata('feedback', 'Invalid Details');
  73. //redirect('Auth');
  74. $this->load->view('login');
  75. }
  76.  
  77. }
  78.  
  79. } ?>
  80.  
  81.  
  82. // Login Model.php functions ------------------------------------------------------------------------------
  83.  
  84. <?php
  85. defined('BASEPATH') OR exit('No direct script access allowed');
  86.  
  87. class Login_model extends CI_Model {
  88.  
  89. public function __construct(){
  90. parent::__construct();
  91. $this->load->library('Notification');
  92. $this->notification = new Notification();
  93. date_default_timezone_set("Asia/Kolkata");
  94.  
  95. }
  96.  
  97. public function Login_check($Username,$password)
  98. {
  99.  
  100. $query = $this->db->query("SELECT * from tbl_employee_master where employee_contact='".$Username."' and employee_password='".$password."'");
  101.  
  102. if($query->num_rows()>0)
  103. {
  104.  
  105. foreach ($query->result() as $row)
  106. {
  107. $employee_id=$row->employee_id;
  108. $Username=$row->employee_name;
  109. $employee_email=$row->employee_email;
  110. $application_id=$row->application_id;
  111. $Password=$row->employee_password;
  112. $employee_contact=$row->employee_contact;
  113. $type=$row->Type;
  114. $imageurl = $row->profile_photo;
  115.  
  116. }
  117. if($this->input->post('Remember')!='')
  118. {
  119. $cookieusername= array(
  120. 'name' => 'Username',
  121. 'value' => $employee_contact,
  122. 'expire' => '86500',
  123. );
  124. $this->input->set_cookie($cookieusername);
  125.  
  126. $cookiepassword= array(
  127. 'name' => 'Password',
  128. 'value' => $Password,
  129. 'expire' => '86500',
  130. );
  131. $this->input->set_cookie($cookiepassword);
  132. }
  133.  
  134.  
  135. $sessiondata = array(
  136. 'employee_id' => $employee_id,
  137. 'Username' => $Username,
  138. 'employee_email' => $employee_email,
  139. 'application_id' => $application_id,
  140. 'type' => $type,
  141. 'photo_url' => $imageurl,
  142. 'logged_in' => TRUE
  143. );
  144.  
  145. $this->session->set_userdata($sessiondata);
  146. return 1;
  147. }
  148. else
  149. {
  150. return 0;
  151. }
  152.  
  153. }
  154.  
  155.  
  156. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement