使用具有每个电子邮件和密码的不同表进行登录验证
Login validation by using different tables having each email and password
我有 4 个表 student、tpo、admin、campany,当用户在登录页面输入值时,每个 table 都有一个列电子邮件和密码,即电子邮件文本和密码文本,然后验证查询检查所有 tables 和 table 具有正确的电子邮件和密码可以登录,但如果登录凭据属于 tpo,则可以显示 tpo 页面,如果登录凭据属于学生,则可以显示学生的其他过程可以在相同的 way.My 表单代码是 asp.net 并且支持的是 c#。
所以我猜您有一个启动其他表单的登录表单。您可以根据找到用户的 table 将登录方法 return 设置为 int,如果未找到用户,则设置为 -1
public static int LogIn(String email, String psw)
{
if((from c in context.student
where c.email==email and c.psw==psw
select c).Any()) {
return 1;
}
if((from c in context.tpo
where c.email==email and c.psw==psw
select c).Any()) {
return 2;
}
if((from c in context.admin
where c.email==email and c.psw==psw
select c).Any()) {
return 3;
}
if((from c in context.campany
where c.email==email and c.psw==psw
select c).Any()) {
return 4;
}
return -1
}
这是因为您认为您有一个 class 用于所有查询,如果没有,您可以启动任何您想要的而不是 returning。
使用此逻辑
创建过程pro_login
Create Procedure pro_login
@Email varchar(max),
@Password varchar(max)
Begin
if exists(select userid from student where userid=@Email and password=@Password)
Begin
select 1
End
else if exists(select userid from tpo where userid=@Email and password=@Password)
Begin
select 2
End
else if exists(select userid from admin where userid=@Email and password=@Password)
Begin
select 3
End
else if exists(select userid from campany where userid=@Email and password=@Password)
Begin
select 4
End
End
&在your.cs页写代码
int res=Login(txtuser.text, txtpass.text);
if(res==1)
{
Response.Redirect("student.aspx");
}
else if(res==2)
{
Response.Redirect("tpo.aspx");
}
else if(res==3)
{
Response.Redirect("admin.aspx");
}
else if(res==4)
{
Response.Redirect("campany.aspx");
}
我有 4 个表 student、tpo、admin、campany,当用户在登录页面输入值时,每个 table 都有一个列电子邮件和密码,即电子邮件文本和密码文本,然后验证查询检查所有 tables 和 table 具有正确的电子邮件和密码可以登录,但如果登录凭据属于 tpo,则可以显示 tpo 页面,如果登录凭据属于学生,则可以显示学生的其他过程可以在相同的 way.My 表单代码是 asp.net 并且支持的是 c#。
所以我猜您有一个启动其他表单的登录表单。您可以根据找到用户的 table 将登录方法 return 设置为 int,如果未找到用户,则设置为 -1
public static int LogIn(String email, String psw)
{
if((from c in context.student
where c.email==email and c.psw==psw
select c).Any()) {
return 1;
}
if((from c in context.tpo
where c.email==email and c.psw==psw
select c).Any()) {
return 2;
}
if((from c in context.admin
where c.email==email and c.psw==psw
select c).Any()) {
return 3;
}
if((from c in context.campany
where c.email==email and c.psw==psw
select c).Any()) {
return 4;
}
return -1
}
这是因为您认为您有一个 class 用于所有查询,如果没有,您可以启动任何您想要的而不是 returning。
使用此逻辑
创建过程pro_loginCreate Procedure pro_login
@Email varchar(max),
@Password varchar(max)
Begin
if exists(select userid from student where userid=@Email and password=@Password)
Begin
select 1
End
else if exists(select userid from tpo where userid=@Email and password=@Password)
Begin
select 2
End
else if exists(select userid from admin where userid=@Email and password=@Password)
Begin
select 3
End
else if exists(select userid from campany where userid=@Email and password=@Password)
Begin
select 4
End
End
&在your.cs页写代码
int res=Login(txtuser.text, txtpass.text);
if(res==1)
{
Response.Redirect("student.aspx");
}
else if(res==2)
{
Response.Redirect("tpo.aspx");
}
else if(res==3)
{
Response.Redirect("admin.aspx");
}
else if(res==4)
{
Response.Redirect("campany.aspx");
}