.aspx制作链接数据库并互相跳转的登录与注册
2012-10-08 13:46:41 来源:WEB开发网}
}
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(sqlserverstr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from Mebiuss where UserName=@UserName";
cmd.Parameters.Add(new SqlParameter("UserName", username.Text));
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
int errorTimes = reader.GetInt32(reader.GetOrdinal("ErrorTimes"));
if (errorTimes > 3)
{
Response.Write("<script>alert('登陆错误次数过多,禁止登陆!');</script>");
return;
}
else
{
string passwrord = reader.GetString(reader.GetOrdinal("PassWord"));
if (passwrord == Password.Text)
{
if (Password.Text == Password2.Text)
{
ResetErrorTimes();
Response.Write("<script>alert('登陆成功');window.location='WebWelcome.aspx';</script>");
}
else
{
Label3.Text="两次密码输入不同,请重新输入!";
Password2.Text = "";
}
}
else
{
IncErrorTimes();
Label2.Text = "密码错误,登陆失败!";
Password.Text = "";
}
}
}
else
{
Label1.Text = "用户名不存在!";
}
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script>window.location='WebZhuCe.aspx';</script>");
}
}
}
更多精彩
赞助商链接