本文介绍了asp登录数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我在尝试让我的网站登录时遇到问题。我希望它在登录时显示适当的消息,但始终显示相同的消息电子邮件不正确 能够帮助我吗?
Hi im having a problem when trying to get my website to log in. I want it to display the appropriate message when I log in but I keep getting the same message "Email is not correct " Would anyone be able to help me this ?
protected void loginbutton_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString); con.Open(); string checkuser = "select count(*) from Users where email =' " + loginemail.Text + "'"; SqlCommand com = new SqlCommand(checkuser, con); int temp = Convert.ToInt32(com.ExecuteScalar().ToString()); con.Close(); if (temp == 1) { con.Open(); string checkPasswordQuery = "select password from Users where email = '" + loginemail.Text + "'"; SqlCommand pass = new SqlCommand(checkPasswordQuery, con); string password = pass.ExecuteScalar().ToString(); if (password == loginpassword.Text) { Session["New"] = loginemail.Text; Response.Write("Password is Correct"); Response.Redirect("Admin.aspx"); } else { Response.Write("Password is not correct"); } } else { Response.Write("Email is not Correct"); } }推荐答案
您的电子邮件旁边有一个空格:
There is an space next to your email:
where email =' " + log...要突出显示它:
where email ='[here there is an empty space] " + log...我认为这是需要更改的地方:
I think this is what needs to change:
string checkuser = "select count(*) from Users where email ='" + loginemail.Text + "'";更多推荐
asp.net登录数据库
发布评论