檢查用戶類型我有我的控制器功能:中的if/else不工作笨
public function verify()
{
$token= $this->uri->segment(3);
$email_verification=$this->load->site_model->verifyEmailAddress($token);
if ($email_verification=== FALSE)
{
redirect('site/index');
}
else
{
$type=$this->load->site_model->select1($token);
//print_r($type);
if($type['user_type']=="Employer"){
redirect('site/emp');
}
else{
redirect('site/seek');
}
}
}
,我的模式是:
<?php
class Site_model extends CI_Model
{
public function __construct()
{
parent:: __construct();
$this->load->database();
}
public function insert($token)
{
$data = array(
'name'=>$this->input->post('name'),
'email'=>$this->input->post('email'),
'phone'=>$this->input->post('phone'),
'user_type'=>$this->input->post('utype'),
'token'=>$token,
);
$this->db->insert('tbl_user',$data);
$email=$this->input->post('email');
$name=$this->input->post('name');
$html ="http://localhost/jobs/hmvc/index.php/site/verify/".$token;
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => '465',
'smtp_user' => '[email protected]',
'smtp_pass' => 'something',
'mailtype' => 'html',
'starttls' => true,
'newline' => "\r\n"
);
$this->load->library('email',$config);
$this->email->From("[email protected]");
$this->email->to($email);
$this->email->subject('test');
$this->email->message('<b>Hi '.$name.' </b><p>Welcome! You’re almost done.!Click the link to confirm your email address..</p>'.$html);
//$this->email->send();
if($this->email->send()) {
echo '<script>alert("Email sent successfully")</script>';
} else {
$this->email->print_debugger();
}
}
public function verifyEmailAddress($token)
{
$data=array('email_verification'=>1);
$this->db->where('token',$token);
$this->db->update('tbl_user',$data);
return true;
}
public function select1($token) {
$this->db->select('user_type');
$this->db->from('tbl_user');
$this->db->where('token',$token);
return $this->db->get()->row();
}
?>
而EM運行錯誤顯示爲致命錯誤的代碼:第89行中的C:\ xampp \ htdocs \ jobs \ hmvc \ application \ modules \ site \ controllers \ site.php中不能使用類型爲stdClass的對象
我該如何解決這個問題? codeigniter中的這個錯誤是什麼意思?
'insert()'沒有返回任何東西。 –
'$ type ['user_type'] ???'你的$類型值不包含任何東西,並且總是去其他條件。 –
那我該怎麼辦? @ Shaiful Islam –