php - set query string in admin login panel in codeignitor -
i have created admin login panel. here model, view, controller file. if login unsuccessful, want sent querystring
. after fetching querystring
value want set message
incorrect email/password
.
i think have modify in catalog_model.php
or else??
my controller(d:\wamp\www\codeigniter\application\controllers\admin\catalog.php)
class catalog extends ci_controller { public function __construct() { parent::__construct(); $this->load->library('session'); $this->load->model('catalog_model'); } function index() { $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); $this->load->view('admin/templates/header'); $this->form_validation->set_error_delimiters('<div class="error_admin">', '</div>'); $this->load->database(); $this->form_validation->set_rules('email', 'email', 'required|valid_email'); $this->form_validation->set_rules('password', 'password', 'required'); if ($this->form_validation->run() == false) { $this->load->view('admin/catalog/catalog_view'); } else { $this->catalog_model->admin_login(); } $this->load->view('admin/templates/footer'); //$html_string = $this->load->view('admin/catalog/catalog_view'); } function logout() { $this->session->unset_userdata('admin_login'); $this->session->unset_userdata('admin_email'); //print_r($this->session->all_userdata()); $this->load->view('admin/catalog/catalog_view'); }
}
my model(d:\wamp\www\codeigniter\application\models\cataalog_model)
<?php class catalog_model extends ci_model { public function __construct() { $this->load->database(); } public function admin_login() { $data = array( 'email' => $this->input->post('email'), 'password' => $this->input->post('password'), ); //return $this->db->insert('school_registration', $data); $query = $this->db->get_where('admin', $data); $rowcount = $query->num_rows(); if($rowcount==1) { $this->session->set_userdata('admin_login', 'true'); $this->session->set_userdata('admin_email', $this->input->post('email')); $this->load->view('admin/catalog/home_view'); } else { $this->load->view('admin/catalog/catalog_view'); //parse_str($_server['query_string'],$_get); } } }
my view(d:\wamp\www\codeigniter\application\views\admin\catalog\catalog_view.php)
<?php if (!defined('basepath')) exit(__('no direct script access allowed')); ?> <div class="light_blue_back" align="center"> <div class="adminbox"> <?php echo form_open('admin/catalog'); ?> <fieldset> <legend><b>admin login</b></legend> <dl> <dt> <label for="street_address1"> <span class="req">*</span>email</label> </dt> <dd> <input type="text" name="email" id="email" value="<?php echo set_value('email'); ?>"/><?php echo form_error('email'); ?> </dd> </dl> <dl> <dt> <label for="street_address2">password</label> </dt> <dd> <input type="password" name="password" id="password" value="<?php echo set_value('password'); ?>"/><?php echo form_error('password'); ?> </dd> </dl> <dl> <dt> </dt> <dd> <?php echo form_submit('reg_sub', 'submit');?> <?php echo form_reset('reg_reset', 'reset');?> </dd> </dl> </fieldset> <?php //echo form_close('admin/catalog'); ?> </form> </div> </div>
you can use set_flashdata
show error message using session function sample code is:
$this->load->library('session'); $this->session->set_flashdata('loginerror', 'username , password mismatch');
you can show loginerror
flashdata
using isset
php function on view page.
for more details visit link:
http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
Comments
Post a Comment