Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // html login.php view ====================================================
- <form class="form-horizontal form-material" method="POST" id="loginform" action="<?php echo base_url(); ?>Auth/logincheck">
- <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>
- <div class="form-group ">
- <div class="col-xs-12">
- <input class="form-control" value="<?php echo $this->input->cookie('Username',true); ?>" name="Username" type="text" required="" placeholder="Username">
- </div>
- </div>
- <div class="form-group">
- <div class="col-xs-12">
- <input class="form-control" value="<?php echo $this->input->cookie('Password',true); ?>" name="password" type="password" required="" placeholder="Password">
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-12">
- <div class="checkbox checkbox-primary pull-left p-t-0">
- <input id="checkbox-signup" <?php if($this->input->cookie('Username',true)!='') {?> checked <?php } ?> type="checkbox" name="Remember">
- <label for="checkbox-signup"> Remember me </label>
- </div>
- <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>
- </div>
- <div class="form-group text-center m-t-20">
- <div class="col-xs-12">
- <button class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light" type="submit">Log In</button>
- </div>
- </div>
- </form>
- // Auth Controller login check function ======================================================================
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Auth extends CI_Controller {
- public function index()
- {
- $this->load->view('login');
- }
- public function logincheck()
- {
- //echo "fgf";
- $Username=$this->input->post('Username');
- $password=$this->input->post('password');
- $result=$this->Login_model->Login_check($Username,$password);
- //$table='';
- //$where=array('is_deleted'=>'N');
- //$ordervalue=('id');
- //$orderfield=('desc');
- //$data['loginresult']=$this->Login_model->Login_check($Username,$password,$table,$where);
- if($result==1)
- {
- $type=$this->session->userdata('type');
- if($type=='D')
- {
- redirect('Patient_reception/Patient_doctor','refresh');
- }
- else
- {
- //redirect('Dashboard','refresh');
- redirect('Patient_reception','refresh');
- }
- }
- else
- {
- $this->session->set_flashdata('feedback', 'Invalid Details');
- //redirect('Auth');
- $this->load->view('login');
- }
- }
- } ?>
- // Login Model.php functions ------------------------------------------------------------------------------
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Login_model extends CI_Model {
- public function __construct(){
- parent::__construct();
- $this->load->library('Notification');
- $this->notification = new Notification();
- date_default_timezone_set("Asia/Kolkata");
- }
- public function Login_check($Username,$password)
- {
- $query = $this->db->query("SELECT * from tbl_employee_master where employee_contact='".$Username."' and employee_password='".$password."'");
- if($query->num_rows()>0)
- {
- foreach ($query->result() as $row)
- {
- $employee_id=$row->employee_id;
- $Username=$row->employee_name;
- $employee_email=$row->employee_email;
- $application_id=$row->application_id;
- $Password=$row->employee_password;
- $employee_contact=$row->employee_contact;
- $type=$row->Type;
- $imageurl = $row->profile_photo;
- }
- if($this->input->post('Remember')!='')
- {
- $cookieusername= array(
- 'name' => 'Username',
- 'value' => $employee_contact,
- 'expire' => '86500',
- );
- $this->input->set_cookie($cookieusername);
- $cookiepassword= array(
- 'name' => 'Password',
- 'value' => $Password,
- 'expire' => '86500',
- );
- $this->input->set_cookie($cookiepassword);
- }
- $sessiondata = array(
- 'employee_id' => $employee_id,
- 'Username' => $Username,
- 'employee_email' => $employee_email,
- 'application_id' => $application_id,
- 'type' => $type,
- 'photo_url' => $imageurl,
- 'logged_in' => TRUE
- );
- $this->session->set_userdata($sessiondata);
- return 1;
- }
- else
- {
- return 0;
- }
- }
- } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement