Assalamualaikum,.. iya benar lupa kita buatkan untuk reseller,
untuk menambahkannya bisa buka file :
C:\xampp\htdocs\marketplace\application\views\reseller\view_login.php
selanjutnya bisa di samakan saja dengan rset password pada admin pada file :
C:\xampp\htdocs\marketplace\application\views\administrator\view_login.php
copas url lupa password dengan memanggil modal form :
ini urlnya : <a class='link' data-dismiss="modal" aria-hidden="true" data-toggle='modal' href='#lupapass' data-target='#lupapass'>Anda Lupa Password?</a>
ini form modalnya :
<div class="modal fade" id="lupapass" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 class="modal-title" id="myModalLabel">Lupa Password Login?</h5>
</div><center>
<div class="modal-body">
<?php
$attributes = array('class'=>'form-horizontal'); echo form_open($this->uri->segment(1).'/lupapassword',$attributes);
?>
<div class="form-group">
<center style='color:red'>Masukkan Email yang terkait dengan akun!</center><br>
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div style='background:#fff;' class="input-group col-sm-8">
<span class="input-group-addon"><i class='fa fa-envelope fa-fw'></i></span>
<input style='text-transform:lowercase;' type="email" class="required form-control" name="email">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3">
<button type="submit" name='lupa' class="btn btn-primary btn-sm">Kirimkan Permintaan</button>
<a data-dismiss="modal" aria-hidden="true" data-toggle='modal' href='#login' data-target='#login' title="Lupa Password Members">Kembali Login?</a>
</div>
</div>
</form><div style='clear:both'></div>
</div>
</center>
</div>
</div>
</div>
terakhir buka file controller reseller :
C:\xampp\htdocs\marketplace_andi\application\controllers\Reseller.php
kemudian tambahkan function lupapassword() modifikasi dari lupapassword administrator :
function lupapassword(){
if (isset($_POST['lupa'])){
$email = strip_tags($this->input->post('email'));
$cekemail = $this->model_app->edit('rb_reseller', array('email' => $email))->num_rows();
if ($cekemail <= 0){
$data['title'] = 'Alamat email tidak ditemukan';
$this->load->view('reseller/view_login',$data);
}else{
$iden = $this->model_app->edit('identitas', array('id_identitas' => 1))->row_array();
$usr = $this->model_app->edit('rb_reseller', array('email' => $email))->row_array();
$this->load->library('email');
$tgl = date("d-m-Y H:i:s");
$subject = 'Lupa Password ...';
$message = "<html><body>
<table style='margin-left:25px'>
<tr><td>Halo $usr[nama_reseller],<br>
Seseorang baru saja meminta untuk mengatur ulang kata sandi Anda di <span style='color:red'>$iden[url]</span>.<br>
Klik di sini untuk mengganti kata sandi Anda.<br>
Atau Anda dapat copas (Copy Paste) url dibawah ini ke address Bar Browser anda :<br>
<a href='".base_url().$this->uri->segment(1)."/reset_password/$usr[password]'>".base_url().$this->uri->segment(1)."/reset_password/$usr[password]</a><br><br>
Tidak meminta penggantian ini?<br>
Jika Anda tidak meminta kata sandi baru, segera beri tahu kami.<br>
Email. $iden[email], No Telp. $iden[no_telp]</td></tr>
</table>
</body></html> \n";
$this->email->from($iden['email'], $iden['nama_website']);
$this->email->to($usr['email']);
$this->email->cc('');
$this->email->bcc('');
$this->email->subject($subject);
$this->email->message($message);
$this->email->set_mailtype("html");
$this->email->send();
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
$data['title'] = 'Password terkirim ke '.$usr['email'];
$this->load->view('reseller/view_login',$data);
}
}else{
redirect($this->uri->segment(1));
}
}
dibawahnya tambahkan function reset_password() untuk menampilakn form untuk proses reset password :
function reset_password(){
if (isset($_POST['submit'])){
$usr = $this->model_app->edit('rb_reseller', array('password' => $this->input->post('id_session')));
if ($usr->num_rows()>=1){
if ($this->input->post('a')==$this->input->post('b')){
$data = array('password'=>hash("sha512", md5($this->input->post('a'))));
$where = array('password' => $this->input->post('id_session'));
$this->model_app->update('rb_reseller', $data, $where);
$row = $usr->row_array();
$this->session->set_userdata(array('id_reseller'=>$row['id_reseller'],
'username'=>$row['username'],
'level'=>'reseller'));
redirect($this->uri->segment(1).'/home');
}else{
$data['title'] = 'Password Tidak sama!';
$this->load->view('reseller/view_reset',$data);
}
}else{
$data['title'] = 'Terjadi Kesalahan!';
$this->load->view('reseller/view_reset',$data);
}
}else{
$this->session->set_userdata(array('id_session'=>$this->uri->segment(3)));
$data['title'] = 'Reset Password';
$this->load->view('reseller/view_reset',$data);
}
}
pada folder application\views\reseller buat 1 file baru dengan nama : view_reset.php
isi dengan script view_reset.php yang saya lampirkan dibawah berikut ini,
sekalian saya lampirkan semua scriptnya dibawah ini biar lebih mudah.
Beres dan silahkan dicobakan reset password resellernya... :)