Guest User

Untitled

a guest
Aug 17th, 2018
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. <form action="<?php echo base_url() . "welcome/forgotpassword" ?>" method="POST">
  2.  
  3. <div class="form-group has-feedback">
  4. <input type="email" class="form-control" placeholder="Email" name="user_email" />
  5. <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
  6. </div>
  7. <div class="row">
  8. <div class="col-xs-4">
  9. <input type="submit" class="btn btn-primary btn-block btn-flat" value="Send">
  10.  
  11. </div>
  12. </div>
  13. </form>
  14.  
  15. public function forgotpassword(){
  16.  
  17. $email = $this->input->post('user_email');
  18. $findemail = $this->main_model->ForgotPassword($email);
  19. $this->load->view('forgotpassword');
  20. if ($findemail) {
  21. $this->main_model->sendpassword($findemail);
  22. } else {
  23.  
  24. $this->session->set_flashdata('msg', 'Email not found!');
  25.  
  26. }
  27. }
  28.  
  29. public function sendpassword($data) {
  30. $email = $data['user_email'];
  31. print_r($data);
  32. $query1 = $this->db->query("SELECT * from user_registration where user_email = '" . $email . "'");
  33. $row = $query1->result_array();
  34.  
  35.  
  36. if ($query1->num_rows() > 0) {
  37.  
  38. $passwordplain = "";
  39. $passwordplain = rand(999999999, 9999999999);
  40. $newpass['user_password'] = md5($passwordplain);
  41. $this->db->where('user_email', $email);
  42. $this->db->update('user_registration', $newpass);
  43. $mail_message = 'Dear ' . $row[0]['full_name'] . ',' . "rn";
  44. $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Your <b>Password</b> is <b>' . $passwordplain . '</b>' . "rn";
  45. $mail_message .= '<br>Please Update your password.';
  46. $mail_message .= '<br>Thanks & Regards';
  47. $mail_message .= '<br>Your company name';
  48. require FCPATH . 'assets/PHPMailer/PHPMailerAutoload.php';
  49. $mail = new PHPMailer;
  50. $mail->isSMTP();
  51. $mail->SMTPSecure = "tls";
  52. $mail->Debugoutput = 'html';
  53. $mail->Host = "ssl://smtp.googlemail.com";
  54. $mail->Port = 465;
  55. $mail->SMTPAuth = true;
  56. $mail->Username = "xxxxxxxxx@gmail.com";
  57. $mail->Password = "xxxxxxxx";
  58. $mail->setFrom('xxxxxxx@gmail.com', 'admin');
  59. $mail->IsHTML(true);
  60. $mail->addAddress('user_email', $email);
  61. $mail->Subject = 'OTP from company';
  62. $mail->Body = $mail_message;
  63. $mail->AltBody = $mail_message;
  64.  
  65. if (!$mail->send()) {
  66.  
  67.  
  68. $this->session->set_flashdata('msg', 'Failed to send password, please try again!');
  69. } else {
  70.  
  71. echo $this->email->print_debugger();
  72. $this->session->set_flashdata('msg', 'Password sent to your email!');
  73. }
  74.  
  75. }
  76. }
  77.  
  78. genererate_new_pass();
  79.  
  80. update_pass()
  81.  
  82. email_new_pass()
  83.  
  84. // all functions will return an error at each stage or not.
  85.  
  86. $this->load->database();
  87.  
  88.  
  89. // load the email class
  90. $this->load->library('email');
  91.  
  92. // mail variables
  93. $this->email->from('your@example.com', 'Your Name');
  94. $this->email->to('someone@example.com');
  95. $this->email->cc('another@another-example.com');
  96. $this->email->bcc('them@their-example.com');
  97.  
  98. $this->email->subject('Email Test');
  99. $this->email->message('Testing the email class.');
  100.  
  101. // send the email
  102. $this->email->send();
Add Comment
Please, Sign In to add comment