Advertisement
timonte

lost_admin

Apr 10th, 2017
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Lost_Admin extends CI_Controller {
  5.  
  6. function __construct()
  7. {
  8. parent::__construct();
  9. $this->load->library('form_validation');
  10. $this->load->model('app_admin');
  11. }
  12.  
  13. public function index()
  14. {
  15. if ($this->input->post('submit', TRUE) == 'Submit')
  16. {
  17. $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
  18. if($this->form_validation->run() == TRUE)
  19. {
  20. $get = $this->app_admin->get_where('t_admin', array('email' => $this->input->post('email', TRUE)));
  21.  
  22. if ($get->num_rows() > 0)
  23. {
  24. //proses
  25. $this->load->library('email');
  26.  
  27. $config['charset'] = 'utf-8';
  28. $config['useragent'] = 'alfatihku';
  29. $config['protocol'] = 'smtp';
  30. $config['mailtype'] = 'html';
  31. $config['smtp_host'] = 'ssl://smtp.gmail.com';
  32. $config['smtp_port'] = '465';
  33. $config['smtp_timeout'] = '5';
  34. $config['smtp_user'] = 'timonte1151@gmail.com';
  35. $config['smtp_pass'] = 'linaneli';
  36. $config['crlf'] = "\r\n";
  37. $config['newline'] = "\r\n";
  38. $config['wordwrap'] = TRUE;
  39.  
  40. $this->email->initialize($config);
  41.  
  42. $key = md5(md5(time()));
  43.  
  44. $this->email->from('timonte1151@gmail.com', "alfatihku");
  45. $this->email->to($this->input->post('email', TRUE));
  46. $this->email->subject('Reset Password');
  47. $this->email->message(
  48. 'Apakah anda lupa dengan password anda ? silahkan klik <a href="'.base_url().'lost_admin/reset/'.$key.'">disini</a> . Jika anda tidak merasa request fitur ini, silahkan abaikan pesan ini'
  49. );
  50.  
  51. if ($this->email->send())
  52. {
  53. $data['reset'] = $key;
  54. $cond['email'] = $this->input->post('email', TRUE);
  55. $this->app_admin->update('t_admin', $data, $cond);
  56.  
  57. $this->session->set_flashdata('success', "Email berhasil dikirim.. silahkan cek email anda");
  58. } else {
  59. $this->session->set_flashdata('alert', "Email gagal dikirim... silahkan coba lagi..");
  60. }
  61.  
  62. } else {
  63. //pesan
  64. $this->session->set_flashdata('alert', "email yang anda masukkan tidak terdaftar");
  65. }
  66. }
  67. }
  68. $this->load->view('lost_pass');
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement