private void btnsubmit_Click(object sender, System.EventArgs e)
{
if(Page.IsValid)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString=ConfigurationSettings.AppSettings["ConnectionString"];
SqlCommand cmd= new SqlCommand();
cmd.CommandText="select user_name,user_pwd from user_info where user_name ='"+this.txtusername.Text+"'";
cmd.Connection = conn;
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
if(reader.Read())
{
if(this.txtpwd.Text.Trim()==reader["user_pwd"].ToString().Trim())
{
Response.Write("<script language = javascript>alert('欢迎您来到我站!');;window.location.replace('enter.aspx');</script>");
}
else
{
Response.Write("<script language = javascript>alert('您输入的密码有误,请重新输入')</script>");
}
}
else
{
Response.Write("<script language = javascript>alert('用户名错误')</script>");
}
reader.Close();
conn.Close();
}
}