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();
}
}