注册新用户时如何显示用户存在以防止多次注册同名。这是我的模型代码。
class ModelUser extends CI_Model {
public function creatAccount()
{
$userId = $_POST['user_id'];
$password = sha1($_POST['password']);
$this->form_validation->set_rules('user_id', 'Userid',
trim|required|valid_userid|is_unique[account.user_id]|xss_clean');
if ($this->form_valudation == false)
return 'User already exist'
}else
{
$this->db->query("INSERT INTO account(user_id,password)
VALUES ('$userId','$password'')");
}