|
为什么第二次注册的字段值与上次一样就提交不了???
比如用户名 admin 已存在,再次注册 admin 时就提交不了,入不了库>_<,控制器里也没加什么判断
大侠们,help~
控制器:
PHP复制代码
//注册
public function insert () {
$table = 'user';
$username = trim($this->input->post('username'));
$email = trim($this->input->post('email'));
$pd = md5(md5(md5($this->input->post('password'))));
$user_data = array(
'username' => $this->input->post('username'),
'password' => $pd,
'email' => $this->input->post('email'),
'regdate' => time('Y-m-d H:i:s')
);
$result = $this->db->insert($table, $user_data);
if($result) {
echo "1";
} else {
echo "2";
}
$this->load->view('register', $data);
}
复制代码
|
|