|
进行测试的时候说我check_name有错误,想了好长时间,也不知道什么原因,是不是我写的有问题啊
Controller
class Member extends TrueManController
{
function Member()
{
parent::TrueManController();
$this->load->model('member_model','',TRUE);
$this->load->helper('url');
$this->load->helper('form');
}
function regisit()
{
if ($_SERVER['REQUEST_METHOD']=='POST')
{
$this->username=$this->input->post('username');
$this->password=$this->input->post('password');
$this->repassword=$this->input->post('password');
$this->email=$this->input->post('email');
if (strlen(strip_tags($this->username))==0
|| strlen(strip_tags($this->password))==0
|| strlen(strip_tags($this->repassword))==0
|| strlen(strip_tags($this->email))==0)
{
$this->message='($function(){alert("请不要带有任何特殊符号,或补全您的信息!");});';
}
elseif ($this->password!=$this->repassword)
{
$this->message='($function(){alert("两次输入的密码不一致!");});';
}
else
{
$get_name=$this->member_model->check_name($this->username);
//var_dump($get_name);
if ($this->username==$get_name)
{
$this->message='($function(){alert("该用户名已存在!");});';
}
else
{
$get_email=$this->member_model->check_email($this->email);
if ($this->email==$get_email)
{
$this->message='($function(){alert("该邮箱已存在!");});';
}
else
{
$this->uid=$this->member_model->regisit($this->username,$this->password,$this->email);
if ($this->uid>0)
{
redirect('index/index'.$_POST['uid']);
}
}
}
}
}
$this->load->view('en/member_regisit_view');
}
Model
class Member_model extends Model
{
function Member_model()
{
parent::Model();
}
function regisit($username,$password,$email)
{
$this->db->set('username', $username);
$this->db->set('password', $password);
$this->db->set('email', $email);
$this->db->insert('user');
return $this->db->insert_id();
}
function check_username($username)
{
$this->db->select('username', $username);
$this->db->from('user');
$get_name=$this->db->get();
return $get_name;
}
function check_email($email)
{
$this->db->select('email', $email);
$this->db->from('user');
$get_email=$this->db->get();
return $get_email;
}
} |
|