Wishlist 0 ¥0.00

报错:SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'admin' for key 'username'

在提交注册信息的时候报错:SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'admin' for key 'username'

原因:主键冲突

 

用户名和邮箱必须唯一,如果填入重复的用户名或者邮箱就会出错

解决方法:在控制器里面进行判断

$data = input('post.');             $uniquename = model('User')->get(['username'=>$data['username']]);             if(sizeof($uniquename)){                 $this->error('该用户名已经注册,请重新填写~~~');             }             $uniqueemail = model('User')->get(['email'=>$data['email']]);             if(sizeof($uniqueemail)){                 $this->error('该邮箱已经注册,请重新填写~~~');             }

添加上面代码之后,如果填写了重复的用户名或者密码就会给用户相关提示~~~

About Us

Since 1996, our company has been focusing on domain name registration, web hosting, server hosting, website construction, e-commerce and other Internet services, and constantly practicing the concept of "providing enterprise-level solutions and providing personalized service support". As a Dell Authorized Solution Provider, we also provide hardware product solutions associated with the company's services.
 

Contact Us

Address: No. 2, Jingwu Road, Zhengzhou City, Henan Province

Phone: 0086-371-63520088 

QQ:76257322

Website: 800188.com

E-mail: This email address is being protected from spambots. You need JavaScript enabled to view it.