• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to SEND LINK in email in codeigniter and how to GET id selected user

#1
Hello guyz i have create small kind of application in codeigniter,in this application i am doing forgot password module, i have created a function of forgot passowrd and send link in email But did not get id in link so how to set id in link, i want id in link and ecrypted pass in method, I need encrypted URL pass in update password view,


Code:
<form id="resetPassword" name="resetPassword" method="POST" action="<?php echo base_url(); ?>welcome/ForgotPassword" onsubmit ='return validate()'>
               <table class="table table-bordered table-hover table-striped">                                      
                   <tbody>
                       <tr>
                           <td>Enter Email: </td>
                           <td>
                               <input type="email" name="user_email" id="email" required>
                           </td>
                       <tr>
                           <td></td>
                           <td><input type = "submit" value="submit" class="button pull-right"></td>
                       </tr>
                   </tbody>    
               </table>
           </form>
Here is my model:
Code:
public function sendpassword($data) {
   $user_email = $data['user_email'];

   $query1 = $this->db->query("SELECT * from user_registration where user_email='" . $user_email . "'");
   $row = $query1->result_array();

   if ($query1->num_rows() > 0) {

       $this->load->library('email');

       //SMTP & mail configuration
       $config = array(
           'protocol' => 'smtp',
           'mailpath' => 'C:\xampp\sendmail',
           'smtp_host' => 'ssl://smtp.googlemail.com',
           'smtp_port' => 465,
           'smtp_user' => 'XXXXXXX@gmail.com',
           'smtp_pass' => 'XXXXXXX',
           'mailtype' => 'html',
           'charset' => 'utf-8'
       );
       $this->email->initialize($config);
       $this->email->set_mailtype("html");
       $this->email->set_newline("\r\n");

       //Email content

       $this->email->from('admin@gmail.com', 'Admin');
       $this->email->to($user_email);
       $this->email->subject('Password reset request');
       $mail_message = 'Dear ' . $row[0]['full_name'] . ',' . "<br>\r\n";
       $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Click On Link And Reset Password:<b><a href="http://www.ciadmin.local/welcome/update_password">Reset Password</a></b>'."\r\n";
       $mail_message .= '<br>Please Update your password.';
       $mail_message .= '<br>Thanks & Regards';
       $mail_message .= '<br>Red Feather Software';

       $this->email->message($mail_message);

       //Send email

       if ($this->email->send()) {

           echo '<script>alert("success..!")</script>';
       } else {
           echo '<script>alert("Please Try Again Later..!")</script>';

       }
   }
}

Controller:
Code:
public function update_password()
{
  $this->load->model("main_model");
    $id = $this->uri->segment(3);
    echo '<script>alert('.$id.')</script>';  
    $this->load->view('update_password');
}
Reply

#2
$userId= $row[0]['id'];
       $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Click On Link And Reset Password:<b><a href="http://www.ciadmin.local/welcome/update_password/$userId">Reset Password</a></b>'."\r\n";
Reply

#3
Never send any user-identifiable info in the link. This article should be required reading for anyone doing password reset/remember me, etc. They have a bunch of good articles on the topic.
Support Development  • Practical CodeIgniter 3  •
Myth:AuthVulcan - CLI Tools for CI4
Reply

#4
(08-19-2018, 01:36 AM)lisheng51 Wrote: $userId= $row[0]['id'];
       $mail_message .= 'Thanks for contacting regarding to forgot password,<br> Click On Link And Reset Password:<b><a href="http://www.ciadmin.local/welcome/update_password/$userId">Reset Password</a></b>'."\r\n";

No dear its now working
Reply

#5
(08-19-2018, 10:48 AM)kilishan Wrote: Never send any user-identifiable info in the link. This article should be required reading for anyone doing password reset/remember me, etc. They have a bunch of good articles on the topic.

Indeed - you should generate temporary key that expires over time, and save that key against user ID in separate table.

Annoying and more secure, sure, but def saves a lot of hurt in the future.

Also, original article bookmarked Smile
Reply

#6
(08-20-2018, 06:09 AM)Pertti Wrote:
(08-19-2018, 10:48 AM)kilishan Wrote: Never send any user-identifiable info in the link. This article should be required reading for anyone doing password reset/remember me, etc. They have a bunch of good articles on the topic.

Indeed - you should generate temporary key that expires over time, and save that key against user ID in separate table.

Annoying and more secure, sure, but def saves a lot of hurt in the future.

Also, original article bookmarked Smile

okok dear
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.