Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($this->input->post('submit'))
- {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $this->db->select('username,password,admin_id');
- $this->db->from('admin');
- $where = "username='$username' and password = '$password'";
- $this->db->where($where);
- $query = $this->db->get();
- $result = $query->row_array();
- $num = $query->num_rows();
- if($num > 0)
- {
- $this->session->set_userdata('admin_id',$result);
- redirect('admin/home');
- }
- else
- {
- echo "<p style='color: red;font-weight: 400;margin-right: 60px;'>Wrong email id or password! </p>";
- }
- }
- ?>
- <form class="form-signin" method="post">
- <input type="text" name="username" id="username" class="form-control" placeholder="username" required autofocus>
- <input type="password" name="password" id="password" class="form-control" placeholder="Password" required>
- <input type="submit" id="submit" name="submit" class="btn btn-lg btn-primary btn-block" value="Sign In">
- </form>
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Admin extends CI_Controller {
- function __construct()
- {
- parent :: __construct();
- $this->load->helper(array('form', 'url', 'captcha', 'email'));
- $this->load->model('ad_data');
- }
- public function home()
- {
- $data['admin_id'] = $this->session->userdata('admin_id');
- print_r($data['admin_id']);
- }
- }
Add Comment
Please, Sign In to add comment