当我输入错误的电子邮件时,我在 Codeigniter 中编写的代码出现以下错误。
遇到 PHP 错误 严重性:注意
消息:尝试获取非对象的属性“电子邮件”
文件名:controllers/forms.php
行号:26
回溯:
文件:E:\Software\XAMPP\xampp\htdocs\ciauth\application\controllers\forms.php 行:26 功能:_error_handler
文件:E:\Software\XAMPP\xampp\htdocs\ciauth\index.php 行:315 功能:require_once
下面是控制器
<?php
class Forms extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library('session');
$this->load->helper('url');
$this->load->model('user_model', 'auth');
}
public function forgot_pass()
{
if($this->input->post('forgot_pass'))
{
$email=$this->input->post('email');
$this->load->model('user_model', 'auth');
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'E-mail', 'required');
if ($this->form_validation->run() == TRUE) {
$que=$this->db->query("select password,email from users where email='$email'");
$row=$que->row();
$user_email=$row->email;
if((!strcmp($email, $user_email)))
{
$pass=$row->password;
$to = $user_email;
$subject = "Password";
$txt = "Your password is $pass .";
$headers = "From: user@testdomain.com" . "\r\n" . "CC: hamza_zon@outlook.com ";
mail($to,$subject,$txt,$headers);
$this->load->view('user/header');
$this->load->view('user/confirm');
$this->load->view('user/footer');
}
else{
$data['error']="Invalid Email ID !";
}
}
else{
$data['error']="Email ID is required !";
}
}
$this->load->view('user/header');
$this->load->view('user/forgot_pass',@$data);
$this->load->view('user/footer');
}
}
?>
鸿蒙传说
慕少森
临摹微笑