Welcome Guest, Not a member yet? Register   Sign In
Where is error , and not update sql row ?
#1

[eluser]pisio[/eluser]
These is part of code for regen. new password for user, and send emil new password.
Code:
if($step == 'nextstep')
       {
          
            $row = $this->db->query("SELECT * FROM  `user` WHERE  `name` =  '{$_POST['name']}' OR `mail` =  '{$_POST['mail']}' LIMIT 1 ");
            foreach($row->result() as $ros)
            {
            $r = $ros->mail;
            $id = $ros->id;
            }


            $length = 5;
            $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
            $string ='';
            for ($p = 0; $p < $length; $p++) {
              $string .= $characters[mt_rand(0, strlen($characters))];
           }

           $new_pass = array('password'=>md5($string),'active'=>0);
           $ws =  "id = ".$uid;
           if($this->db->update_string('user', $new_pass, $ws))
           {
               $this->email->from('[email protected]', 'WikiScript');
               $this->email->to($r);
               $this->email->subject('Activate  your acc.');

               $text = 'http://localhost/wiki/index.php/userpage/forgotpassword/laststep/'.$id;
               $text .= "\n\r  New password is :{$string}";
               $this->email->message($text);
               $this->email->send();
               $step = 2;

               echo $string;
               echo "<br/> $text";
           }
       }
And How I can see mysql error if there are ?
#2

[eluser]Mischievous[/eluser]
it should be displaying if there are errors... unless you have your php setting to not display errors? whats the reasoning for grabbing errors?
#3

[eluser]pisio[/eluser]
By default it shows. But now I know why not change the fields.
#4

[eluser]pisio[/eluser]
I'm so stupyd.
And I so sorry my English is not very good.
The problem was fixed before 5 mins.
Code:
function forgotpassword()
    {
       $step =  $this->uri->segment(3);
       $uid  =  $this->uri->segment(4);
       if($step == NULL)
       {
         $step = 1;
       }
       if($step == 'nextstep')
       {
          
            $row = $this->db->query("SELECT * FROM  `user` WHERE  `name` =  '{$_POST['name']}' OR `mail` =  '{$_POST['mail']}' LIMIT 1 ");
            foreach($row->result() as $ros)
            {
            $r = $ros->mail;
            $id = $ros->id;
            }


            $length = 5;
            $characters = '0123456789abcdefghijklmnopqrstuvwxyz';
            $string ='';
            for ($p = 0; $p < $length; $p++) {
              $string .= $characters[mt_rand(0, strlen($characters))];
           }
           $msd =  md5($string);
           $new_pass = array('password'=>$msd,'active'=>'0');
           $ws =  "id = ".$ros->id;
           $update = $this->db->update_string('user', $new_pass, $ws);
           if($this->db->query($update))
           {
               $this->email->from('[email protected]', 'WikiScript');
               $this->email->to($r);
               $this->email->subject('Activate  your acc.');

               $text = 'http://localhost/wiki/index.php/userpage/forgotpassword/laststep/'.$id;
               $text .= "\n\r  New password is :{$string}";
               $this->email->message($text);
               $this->email->send();
               $step = 2;
           }

       }
       if($step == 'laststep'){
           $data = array('active'=>'1');
           $where = "id = '".$uid."' LIMIT 1 ";
           $str = $this->db->update_string('user', $data, $where);

           if($str){
               $step = 3;
           } else {
               $step = 4;
           }
       }


       $this->load->view('user_passrecovery',array('step' => $step));
    }




Theme © iAndrew 2016 - Forum software by © MyBB