cookies - Having trouble with codeigniter check box on remember me button -
i storing username , password in cookie have little trouble remember me button want when user check check box cookie store values else log in user problem here when put check in controller wont work know problem in if condition please 1 sort me out problem or correct syntax thankful. here code of controller , view.
function verifying(){ $data=array( 'username'=>$this->input->post('username'), 'password'=>$this->input->post('password') ); if($this->input->post('remember_me')=="checked") { $cookie = array( 'name' => 'username', 'value' => $this->input->post('username'), 'expire' => 86500, 'secure' => false ); $cookie1 = array( 'name' => 'password', 'value' => $this->input->post('password'), 'expire' => 86500, 'secure' => false ); } $this->input->set_cookie($cookie); $this->input->set_cookie($cookie1); $result=$this->user->verify("signup",$data); if($result) { $sess_arrau=array(); foreach($result $row) { $sess_arrau=array('username'=>$row->username); } $this->session->set_userdata($sess_arrau); $data['username']=$this->session->userdata('username'); $this->load->view("success",$data); } //$this->load->view("success",$sess_array); else{ redirect("signin"); } }
log in page code.
<?php $username=$this->input->cookie('username', false); $password=$this->input->cookie('password',false); if($this->session->userdata('username')!=''){ redirect("index/post"); } echo form_open("index/verifying"); echo form_input('username',"$username",'placeholder="username"'); echo form_checkbox('remember_me','remember me',false); echo form_label('remember me','remember_me'); ?> </div> </div> <div class="row"> <div class="col-lg-12"> <?php echo form_password('password',"$password",'placeholder="password"'); echo form_submit('submit','signin'); echo form_close(); ?>
your problem "checked" won't value of input when has been checked. instead value "remember me" because second parameter have passed form_checkbox
function.
so in controller rather do
if($this->input->post('remember_me')=="checked") { //do stuff here... }
you need do
if($this->input->post('remember_me')=="remember me") { //do stuff here... }
Comments
Post a Comment