Guest User

Untitled

a guest
Apr 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2. if($this->input->post('submit'))
  3. {
  4. $username = $this->input->post('username');
  5. $password = $this->input->post('password');
  6.  
  7. $this->db->select('username,password,admin_id');
  8. $this->db->from('admin');
  9. $where = "username='$username' and password = '$password'";
  10. $this->db->where($where);
  11. $query = $this->db->get();
  12. $result = $query->row_array();
  13. $num = $query->num_rows();
  14. if($num > 0)
  15. {
  16. $this->session->set_userdata('admin_id',$result);
  17. redirect('admin/home');
  18. }
  19. else
  20. {
  21. echo "<p style='color: red;font-weight: 400;margin-right: 60px;'>Wrong email id or password! </p>";
  22. }
  23. }
  24. ?>
  25. <form class="form-signin" method="post">
  26. <input type="text" name="username" id="username" class="form-control" placeholder="username" required autofocus>
  27. <input type="password" name="password" id="password" class="form-control" placeholder="Password" required>
  28. <input type="submit" id="submit" name="submit" class="btn btn-lg btn-primary btn-block" value="Sign In">
  29. </form>
  30.  
  31. <?php
  32. defined('BASEPATH') OR exit('No direct script access allowed');
  33. class Admin extends CI_Controller {
  34. function __construct()
  35. {
  36. parent :: __construct();
  37. $this->load->helper(array('form', 'url', 'captcha', 'email'));
  38. $this->load->model('ad_data');
  39. }
  40. public function home()
  41. {
  42. $data['admin_id'] = $this->session->userdata('admin_id');
  43. print_r($data['admin_id']);
  44. }
  45. }
Add Comment
Please, Sign In to add comment