如果用户名已存在于数据库中,如何在注册表单中进行标记 [英] How to mark in a registration form if username already exists in the database

查看:159
本文介绍了如果用户名已存在于数据库中,如何在注册表单中进行标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个注册表,它运行良好并将数据导入到mysql数据库中,但我需要输入如果用户名已存在于数据库中,如果存在警报,如果没有,请继续注册。









提前致谢。

解决方案

此查询将帮助你,

  SELECT  Id,Name,COUNT (*)
FROM 用户
GROUP BY firstname,lastname
HAVING COUNT(*)> 1 ;



请参阅代码段 here [ ^ ]。



-KR


唯一的方法是在服务器端处理这种验证。基本上,您需要从表单处理HTTP请求并生成一些页面,该页面应告知用户验证结果,而不是进一步处理请求。理想情况下,您应该使用表单生成与请求表单相同的页面,使用相同的URL,只添加验证结果。例如,它应该全部到输入用户名的行:用户名已存在。



-SA

I made a registration form , it works well and import the data into the mysql database , but i need to put if the username already exists in the database , if exists alert , if not ,keep with the registration.




Thanks in advance.

解决方案

This query will help ya,

SELECT Id, Name, COUNT(*)
FROM User
GROUP BY firstname, lastname
HAVING COUNT(*) > 1;


See the snippet here[^].

-KR


The only way to do that is to process this kind of validation on the server side. Basically, you need process HTTP request from the form and to generate some page which should tell the user the validation results, instead of further processing the request. Ideally, you should generate the same page with the form as the request form, with the same URL, only add your validation results. For example, it should all to the line where the user name is entered: "User name already exists".

—SA


这篇关于如果用户名已存在于数据库中,如何在注册表单中进行标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆