select * from table where @userinput = (phone or @userinput = email) and @password = pwd
用类似这样的查询,or一下就可以了。假设userinput和password是输入
做下判断就好了,有@和.com的字符串是邮箱,11位数字的书是手机号,其他的情况是用户名。需要注意的是在注册的时候用户名不能有@符号。
就酱
要保证登记的邮箱和手机号是唯一的,做这样一个功能才有用,
可以用正则匹配userid的类型,再拼接SQL
regTel=/^\d{13,13}$/ regMail=/^\w+@\w+.\w+$/,regUserId=/^\w+$/
或者是 select * from tbUser where userid=@userid or email=@userid or tel=@userid password=@pwd这样的语句判断