登录页面(login)

来源:互联网 发布:python端口扫描器 编辑:程序博客网 时间:2024/04/29 08:00

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

             

              }

         }

原创粉丝点击