Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="<?php echo base_url() . "welcome/forgotpassword" ?>" method="POST">
- <div class="form-group has-feedback">
- <input type="email" class="form-control" placeholder="Email" name="user_email" />
- <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
- </div>
- <div class="row">
- <div class="col-xs-4">
- <input type="submit" class="btn btn-primary btn-block btn-flat" value="Send">
- </div>
- </div>
- </form>
- public function forgotpassword(){
- $email = $this->input->post('user_email');
- $findemail = $this->main_model->ForgotPassword($email);
- $this->load->view('forgotpassword');
- if ($findemail) {
- $this->main_model->sendpassword($findemail);
- } else {
- $this->session->set_flashdata('msg', 'Email not found!');
- }
- }
- public function sendpassword($data) {
- $email = $data['user_email'];
- print_r($data);
- $query1 = $this->db->query("SELECT * from user_registration where user_email = '" . $email . "'");
- $row = $query1->result_array();
- if ($query1->num_rows() > 0) {
- $passwordplain = "";
- $passwordplain = rand(999999999, 9999999999);
- $newpass['user_password'] = md5($passwordplain);
- $this->db->where('user_email', $email);
- $this->db->update('user_registration', $newpass);
- $mail_message = 'Dear ' . $row[0]['full_name'] . ',' . "rn";
- $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Your <b>Password</b> is <b>' . $passwordplain . '</b>' . "rn";
- $mail_message .= '<br>Please Update your password.';
- $mail_message .= '<br>Thanks & Regards';
- $mail_message .= '<br>Your company name';
- require FCPATH . 'assets/PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->SMTPSecure = "tls";
- $mail->Debugoutput = 'html';
- $mail->Host = "ssl://smtp.googlemail.com";
- $mail->Port = 465;
- $mail->SMTPAuth = true;
- $mail->Username = "xxxxxxxxx@gmail.com";
- $mail->Password = "xxxxxxxx";
- $mail->setFrom('xxxxxxx@gmail.com', 'admin');
- $mail->IsHTML(true);
- $mail->addAddress('user_email', $email);
- $mail->Subject = 'OTP from company';
- $mail->Body = $mail_message;
- $mail->AltBody = $mail_message;
- if (!$mail->send()) {
- $this->session->set_flashdata('msg', 'Failed to send password, please try again!');
- } else {
- echo $this->email->print_debugger();
- $this->session->set_flashdata('msg', 'Password sent to your email!');
- }
- }
- }
- genererate_new_pass();
- update_pass()
- email_new_pass()
- // all functions will return an error at each stage or not.
- $this->load->database();
- // load the email class
- $this->load->library('email');
- // mail variables
- $this->email->from('your@example.com', 'Your Name');
- $this->email->to('someone@example.com');
- $this->email->cc('another@another-example.com');
- $this->email->bcc('them@their-example.com');
- $this->email->subject('Email Test');
- $this->email->message('Testing the email class.');
- // send the email
- $this->email->send();
Add Comment
Please, Sign In to add comment