Forgot password with generated code in CodeIgniter
<p>I have generated random code but I cannot update it with password from database table.</p>

<p>Below is my forgot password controller code:</p>

<pre><code>public function forgot(){
    if($this-&gt;input-&gt;post('submit')) {
        $email = $this-&gt;input-&gt;post('email');
        $qry['email'] = $this-&gt;Employer_model-&gt;select($email);
        $email1 = $qry['email']-&gt;email;

        if($email1 == $email) {
            $code1 = rand();
            $code = md5($code1);
            $employer_id = $GLOBALS['employer_id'];
            $qry1 = $this-&gt;Employer_model-&gt;insertpwd($code, $employer_id);

            if($qry1) {
                echo "&lt;script&gt;alert(' your new password is $code1!')&lt;/script&gt;";
            }
        }
    }

    $this-&gt;load-&gt;view('employer/forgot');
}
</code></pre>