As i told, if i refresh the page email is getting in the field but i need that before page refresh
控制器代码 公共函数ResetPassword(){
$emaill = $this->input->post('emaill');
$otp = $this->input->post('otp');
//$this->form_validation->set_rules('emaill', 'emaill', 'required|min_length[10]|max_length[30]|matches[otp]');
$this->form_validation->set_rules('otp', 'otp', 'required|min_length[6]|max_length[6]');
$this->form_validation->set_rules('newpassword', 'newpassword', 'trim|required|max_length[15]|min_length[8]|alpha_numeric|matches[confirmpassword]');
$this->form_validation->set_rules('confirmpassword', 'Confirm password', 'trim|required');
if ($this->form_validation->run() == FALSE) {
$this->load->view('login');
} else {
if($this->session->userdata('otp') == "$otp" && $this->session->userdata('findemaill') == "$emaill" ) {
$user = $this->session->userdata('findemaill');
$this->load->model('Login_model');
$result['data'] = $this->Login_model->resetpassword($user);
$result['data1'] = $this->Login_model->resetpasswordd($user);
$this->session->set_flashdata('success_msg', 'successfull reset the password');
$this->load->view('login');
}
}
}
型号代码
public function resetpassword($user) {
$new_password = $this->input->post('newpassword');
$this->db->set('password',$new_password);
$this->db->where('email',$user );
$this->db->update('supplier_registration');
}
public function resetpasswordd($user) {
$new_password = $this->input->post('newpassword');
$this->db->set('password',$new_password );
$this->db->where('email',$user);
$this->db->update('customer_registration');
}
查看页面
<form action="<?php echo base_url(); ?>Index.php/Login_cntrl/ResetPassword" method="POST">
<div class="field-wrap">
<input type="text" name="emaill" id="emaill" placeholder="Enter your Mobile/Email Address" value="<?php echo $this->session->userdata('findemaill'); ?>" autocomplete="off" id="forgot-email"/>
</div>
<div class="field-wrap">
<input type="text" name="otp" id="otp" placeholder="Enter OTP" value="<?php echo set_value('otp'); ?>"/>
<span class="text-danger"><?php echo form_error('otp'); ?></span>
</div>
<?php echo $this->session->flashdata('passwordmissmatch'); ?>
<div class="field-wrap">
<input type="text" name="newpassword" id="newpassword" placeholder="Enter new Password" value="<?php echo set_value('newpassword'); ?>"/>
<span class="text-danger"><?php echo form_error('newpassword'); ?></span>
</div>
<div class="field-wrap">
<input type="text" name="confirmpassword" id="confirmpassword" placeholder="Re-enter new Password" value="<?php echo set_value('confirmpassword'); ?>"/>
<span class="text-danger"><?php echo form_error('confirmpassword'); ?></span>
</div>
<div class="field-wrap">
<button type="submit" name="resubmit" id="resubmit" class="btn btn-submit">submit</button>
</div>
<?php echo $this->session->flashdata('success_msg'); ?>
<div class="field-wrap">
<a href="javascript:void(0)" class="btn-show-login btn btn-link btn-nobg" >Back</a>
</div>
</form>
忘记了页面链接表单
<form action="<?php echo base_url(); ?>Index.php/Login_cntrl/login" method="POST" >
<div class="field-wrap">
<label class="view-label">Email Address</label>
<input type="email" placeholder="Email Address" name="email" id="email" class="input-control" value="<?php echo set_value('email'); ?>"/>
<span class="text-danger"><?php echo form_error('email'); ?></span>
</div>
<div class="field-wrap">
<input type="password" placeholder="Password" name="password" id="password" value="<?php echo set_value('password'); ?>" />
<span class="text-danger"><?php echo form_error('password'); ?></span>
<a href="javascript:void(0)" class="btn btn-link btn-nobg" id="btn-show-forgot" >Forgot ?</a>
</div>
<div class="field-wrap">
<button type="submit" class="btn btn-submit" name="ulogin" id="ulogin" >Login</button>
</div>
<div class="field-wrap">
<a href="javascript:void(0)" class="btn btn-link btn-nobg" id="btn-show-signup">NEW User? Sign up</a>
</div>
</form>
答案 0 :(得分:0)
你可以使用jquery:
$('.forgotLink').click(function (e) {
e.preventDefault();
window.location = $(this).attr('href') + '?email=' + encodeURIComponent($('#email').val());
});