我正在做代碼點火器中的密碼重置功能。我是新的框架。如何解決截斷不正確的DOUBLE值?
我控制器調用user_forgot_password_con 和模式是在控制器user_forgot_password_model
我有兩個功能 一個是user_forgot_password_process() 該功能拍攝的電子郵件用戶檢查數據庫,並把郵件發送到電子郵件鏈接http://localhost/codeigniter/user_forgot_password_con/user_new_password_process/?email「 。$ to_email。 ''
另一個功能是user_new_password_process() 此功能允許用戶輸入新密碼
型號是user_forgot_password_model
已經3個功能之一是獲取用戶的電子郵件,檢查電子郵件 二是sendmail發送電子郵件
第三是更新用戶的密碼更新密碼..
發送電子郵件等事情是工作後
當鏈路咯咯叫着我得到在同一控制器超視距雷達的功能是電子郵件,通過$email= $this->input->get("email");
輸入新的密碼,並更新表,我得到這個錯誤
數據庫出錯 錯誤號碼:1292 截斷不正確DOUBLE值: '[email protected]' UPDATE
register
SETpassword
= 0 WHERE
如何解決呢..
我的控制器代碼
<?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
}
@tereško - 沒有人應該用php開始新項目。而這些基於意見的答案對任何人都沒有幫助。 – shaggy
你爲什麼使用DOUBLE作爲電子郵件地址?電子郵件是字符串。 –
我沒有在數據庫中使用Double。它還在... –