用户登录界面验证代码
protected void Button1_Click(object sender, EventArgs e)
{
string connStr = System.Configuration.ConfigurationSettings.AppSettings["connString"];
SqlConnection myConnection = new SqlConnection(connStr);
string checkStr = "select count(*) from bbs_register where (username='"+username.Text+"' and pwd='"+password.Text+"')";
SqlCommand cmd = new SqlCommand(checkStr,myConnection);
myConnection.Open();
int flag = (int)cmd.ExecuteScalar();
myConnection.Close();
if (flag > 0)
{
Session["username"] = username.Text;
Response.Redirect("show.aspx");
}
else
{
Label4.Text = "用户名或密码有误,请重新输入!";
Label4.ForeColor = Color.Red;
}
}
{
string connStr = System.Configuration.ConfigurationSettings.AppSettings["connString"];
SqlConnection myConnection = new SqlConnection(connStr);
string checkStr = "select count(*) from bbs_register where (username='"+username.Text+"' and pwd='"+password.Text+"')";
SqlCommand cmd = new SqlCommand(checkStr,myConnection);
myConnection.Open();
int flag = (int)cmd.ExecuteScalar();
myConnection.Close();
if (flag > 0)
{
Session["username"] = username.Text;
Response.Redirect("show.aspx");
}
else
{
Label4.Text = "用户名或密码有误,请重新输入!";
Label4.ForeColor = Color.Red;
}
}
浙公网安备 33010602011771号