Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php echo validation_errors(); ?>
- <form action="<?= base_url() ?>verifylogin" method="post" name="menuForm" class="form-horizontal">
- <div class="form-group">
- <div class="col-md-12">
- <label for="username"></label>
- <input type="text" class="form-control" placeholder="E-mail" id="txtusername"/>
- </div>
- </div>
- <div class="form-group">
- <div class="col-md-12">
- <label for="password"></label>
- <input type="password" class="form-control" placeholder="Password" id="txtpassword"/>
- </div>
- </div>
- <br>
- <div class="form-group">
- <div class="col-md-6">
- <a href="#" class="btn btn-link btn-block">Forgot your password?</a>
- </div>
- <div class="col-md-6">
- <button class="btn btn-info btn-block">Log In</button>
- </div>
- </div>
- </form>
- ------------------------------------
- controller
- ---------------------
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Verifylogin extends CI_Controller {
- function __construct()
- {
- parent::__construct();
- $this->load->model('modLogin','',TRUE);
- }
- function index()
- {
- print_r( $this->input->post());
- $email = $this->input->post('txtusername');
- $password = $this->input->post('txtpassword',TRUE);
- // echo ' - ' . $password . $email;
- die();
- $this->load->library('form_validation');
- $this->load->helper(array('form', 'url'));
- $this->form_validation->set_rules('username', 'Username', 'required');
- $this->form_validation->set_rules('password', 'Password', 'required');
- // $this->form_validation->set_rules('username', 'Username', 'trim|required|valid_email|xss_clean');
- //$this->form_validation->set_rules('password', 'Password', 'trim|required|sha1');
- $email = $this->input->post('username');
- $password = $this->input->post('password');
- echo $password . $email;
- die();
- if($this->form_validation->run() == FALSE)
- {
- $this->load->view('vlogin');
- }
- else
- {
- redirect('home', 'refresh');
- }
- }
- function check_database($password)
- {
- //Field validation succeeded. Validate against database
- $username = $this->input->post('username');
- //query the database
- $result = $this->MLogin->login($username, $password);
- if($result)
- {
- $sess_array = array();
- foreach($result as $row)
- {
- $sess_array = array(
- 'id' => $row->id,
- 'username' => $row->username
- );
- $this->session->set_userdata('logged_in', $sess_array);
- }
- return TRUE;
- }
- else
- {
- $this->form_validation->set_message('check_database', 'Invalid username or password');
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement