2017-05-14 46 views
-1

コードイグナイターでパスワードリセット機能を実行しています。私はこのフレームワークに新しいものです。切り捨てられた不正なDOUBLE値を解決するにはどうすればよいですか?

私は user_forgot_password_con呼び出され、コントローラを持っているモデルは、コントローラに

user_forgot_password_modelである私は2つの機能 1を持っているが、この機能は、データベース内のユーザーのチェックからの電子メールを取り、リンクhttp://localhost/codeigniter/user_forgot_password_con/user_new_password_process/?emailでそのメールにメールを送信user_forgot_password_process() は ' 。$のto_email。 ''

別の機能がuser_new_password_process()であるが この機能は、ユーザーが新しいパスワードを入力することができます

モデルは、それが3機能1が 第二は、電子メール

を送信するためにsendmailのある

第三には、パスワードを更新するための更新ユーザーのパスワードでメールをチェックするために、ユーザーの電子メールを取得されてい

user_forgot_password_model ..です

電子メールやその他を送ります事はリンクがcluckedされたとき、私は後$email= $this->input->get("email");

を通じて同じコントローラにOTHR機能でその電子メールを取得しています

を働いています新しいパスワードを入力し、テーブルを更新し、私はこのエラーを取得しています

データベースエラーが エラー番号発生しました

:1292 切り捨てられた間違ったDOUBLE値: '[email protected]' UPDATE register SETをpassword = 0 email = 0 ファイル名:C:\ wamp64 \ WWW \ CodeIgniterのシステム\データベース\ DB_driver.php 行番号\:331

それを解決する方法

..

私のコントローラコードが

<?php 
 

 
through CI 
 

 
Class User_forgot_password_con extends CI_Controller { 
 

 
public function __construct() 
 
\t { 
 
\t \t parent::__construct(); 
 
\t \t 
 
\t \t $this->load->model('user_forgot_password_model'); 
 
\t } 
 

 
// Show login page 
 
public function index() 
 
    { 
 
\t 
 
     $this->user_forgot_password_process(); 
 
\t 
 
    } 
 
\t 
 
\t //Forgot Password Link Sending.... 
 
\t public function user_forgot_password_process() 
 
\t { 
 
\t \t // get form input 
 
\t \t $email = $this->input->post("email"); 
 
     
 
\t \t // form validation 
 
\t \t $this->form_validation->set_rules("email", "Email-ID", "trim|required|xss_clean"); 
 
\t \t 
 
\t \t 
 
\t \t if ($this->form_validation->run() == FALSE) 
 
     { 
 
\t \t \t // validation fail 
 
\t \t \t $this->load->view('header'); 
 
\t \t \t $this->load->view('user_forgot_password_view'); 
 
\t \t \t $this->load->view('footer'); 
 
\t \t } 
 
\t \t 
 
\t \t else 
 
\t \t { 
 
\t \t \t $uresult = $this->user_forgot_password_model->get_user_email($email); 
 
\t \t \t if (count($uresult) > 0) 
 
\t \t \t { 
 
\t \t \t \t //send mail 
 
\t \t \t \t if ($this->user_forgot_password_model->sendEmail($this->input->post('email'))) 
 
\t \t \t \t { 
 
\t \t \t \t \t // successfully sent mail 
 
\t \t \t \t \t $this->session->set_flashdata('msg','<div class="alert alert-success text-center">Password Reset Link Is Sent To Your Email Reset Your Password..!!!</div>'); 
 
\t \t \t \t \t $this->load->view('header'); 
 
\t \t \t \t \t redirect('user_forgot_password_con/user_forgot_password_process'); 
 
\t \t \t \t \t $this->load->view('footer'); 
 
\t \t \t \t } 
 
\t \t \t \t else 
 
\t \t \t \t { 
 
\t \t \t \t \t // error 
 
\t \t \t \t \t $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Email Not Registered...</div>'); 
 
\t \t \t \t \t $this->load->view('header'); 
 
\t \t \t \t \t redirect('user_forgot_password_con/user_forgot_password_process'); 
 
\t \t \t \t \t $this->load->view('footer'); 
 
\t \t \t \t } \t 
 
\t \t \t } 
 
\t \t \t 
 
\t \t \t else 
 
\t \t \t { 
 
\t \t \t \t // error 
 
\t \t \t \t $this->session->set_flashdata('msg','<div class="alert alert-danger text-center">Email Not Registered..</div>'); 
 
\t \t \t \t $this->load->view('header'); 
 
\t \t \t \t redirect('user_forgot_password_con/user_forgot_password_process'); 
 
\t \t \t \t $this->load->view('footer'); 
 
\t \t \t } 
 
\t \t \t \t 
 
\t \t } \t \t 
 
\t } 
 
\t 
 
\t 
 
\t public function user_new_password_process() 
 
\t { 
 
\t \t $password = $this->input->post("passwword"); 
 
\t \t 
 
\t \t $cpassword= $this->input->post("cpasswword"); 
 
\t \t 
 
\t \t $this->form_validation->set_rules('password', 'Password', 'trim|required|md5'); 
 
\t \t $this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required|matches[password]|md5'); 
 
\t \t 
 
\t \t if ($this->form_validation->run() == FALSE) 
 
     { 
 
\t \t \t // validation fail 
 
\t \t \t $this->load->view('header'); 
 
\t \t \t $this->load->view('user_new_password_view'); 
 
\t \t \t $this->load->view('footer'); 
 
\t \t } 
 
\t \t 
 
\t \t else 
 
\t \t { 
 
\t \t  $email= $this->input->get("email"); 
 
\t \t \t 
 
      \t $this->user_forgot_password_model->update_user_password($email,$password); 
 
\t \t \t 
 
\t \t \t 
 
\t \t \t 
 
\t \t } 
 
\t \t 
 
\t \t 
 
\t \t 
 
\t \t 
 
\t \t 
 
\t \t 
 
\t } 
 
\t 
 
\t 
 
} 
 

 
?>

である私のモデルは、まあ、私はあなたにいくつかのことを伝えることができ

<?php 
 
class user_forgot_password_model extends CI_Model 
 
{ 
 
\t function __construct() 
 
    { 
 
     // Call the Model constructor 
 
     parent::__construct(); 
 
    } 
 
\t 
 
\t function get_user_email($email) 
 
\t { 
 
\t \t 
 
\t \t $this->db->where('email', $email); 
 
     $query = $this->db->get('register'); 
 
\t \t return $query->result(); 
 
\t \t 
 
\t \t 
 
\t } 
 
\t 
 
\t //send verification email to user's email id 
 
\t function sendEmail($to_email) 
 
\t { 
 
\t \t $from_email = '[email protected]'; 
 
\t \t $subject = 'Reset Password Link...'; 
 
\t \t $message = 'Dear User, Please click on the below link to Reset your password. 
 
\t \t     http://localhost/codeigniter/user_forgot_password_con/user_new_password_process/?email'.$to_email.''; 
 
\t \t 
 
\t \t //configure email settings 
 
\t \t 
 
\t \t $this->email->initialize(); \t 
 
\t \t //send mail 
 
\t \t $this->email->from($from_email, 'Mydomain'); 
 
\t \t $this->email->to($to_email); 
 
\t \t $this->email->subject($subject); 
 
\t \t $this->email->message($message); 
 
\t \t return $this->email->send(); 
 
\t } 
 
\t 
 
\t // Update Table 
 
\t 
 
\t function update_user_password($email,$password) 
 
\t { 
 
\t \t $data = array('password' => $password); 
 
\t \t $this->db->where('email', $email); 
 
\t \t return $this->db->update('register', $data); 
 
\t } 
 
\t 
 
\t 
 
}

+1

@tereško - 誰にも通知する必要はありませんPHPで新しいプロジェクトを開始するそして、これらの意見に基づく答えは誰にも役立たない。 – shaggy

+0

なぜ電子メールアドレスにDOUBLEを使用していますか?電子メールは文字列です。 –

+0

データベースでDoubleを使用しませんでした。それはまだ来る.. –

答えて

0

です。まず、エラーメッセージはString(電子メール)とDouble(0)を比較しているため、電子メールの取得が機能していないことを意味します。

http://localhost/codeigniter/user_forgot_password_con/user_new_password_process/?email'.$to_email. 

私はあなたがあなたのリンクの終わり近く=が欠けていると思う - >?email='.$to_email.'、それにそれはあなたがフェッチする必要があるので、それだけで、リンクの一部となることなしに、GET経由ため、フェッチ可能な、変数のそれは$this->uri()->segment(3)を経由して、[email protected]のような文字列になります。あなたはそれを望んでいません。プライベートデータをリンクに渡すことは悪い習慣です。だれかがすぐにそのメールのリセット機能を呼び出すことができます。私はちょうどhttp://localhost/codeigniter/user_forgot_password_con/user_new_password_process/[email protected]をタイプします私はちょうどあなたが安全にユーザーのパスワードをリセットする方法の多くの研究をする必要がないならば、これは学校のプロジェクトであることを願っています。

$password = $this->input->post("passwword"); 

$cpassword= $this->input->post("cpasswword"); 

しかし、何がそこにありません:

user_new_password_process機能では、私はまっすぐにそのリンクからメールで、それはPOSTからいくつかのデータを読み込むしようとしているメソッドが表示されますので、何も動作することを考えます。に移動すると、2つのフィールドを含むフォームが表示され、メールを送信する必要があります。user_new_password_process

関連する問題