« ASP.NET-GridView的分页功能access转sql server »

.net 登陆代码

    protected void Button1_Click(object sender, EventArgs e)
    {
        string myconnectionstring = System.Configuration.ConfigurationManager.AppSettings["connstr"];
        string mycommandstring = "SELECT * FROM who where who_name=" + "'" + TextBox1.Text + "'" + "and who_pwd = " + "'" + TextBox2.Text+ "'";
        SqlConnection myconnection = new SqlConnection(myconnectionstring);
     
        SqlCommand mycommand = new SqlCommand(mycommandstring, myconnection);
        myconnection.Open();
        SqlDataReader myreader = mycommand.ExecuteReader();
        if (myreader.Read())
        {
          Session["name"] = myreader["who_name"].ToString();
          Response.Redirect("postdoing.aspx");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码不正确,请重新登陆');</script>");
            Response.Redirect("login.aspx");
        }
    }


    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = TextBox2.Text = "";
    }

  • 相关文章:
  • quote 1.jeffersyuan
  • string mycommandstring = "SELECT * FROM who where who_name=" + "'" + TextBox1.Text + "'" + "and who_pwd = " + "'" + TextBox2.Text+ "'";

    这种有明显的漏洞攻击!
    请更改吧!
  • 2007-11-10 16:34:33 回复该留言
  • quote 2.tony
  • jeffersyuan兄,这个该怎么改呢
    我刚从asp转成.net选手,对安全这方面还没研究。
    请指点一二。
  • 2007-11-10 18:48:14 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Theme by toboku


邓三少远在上海的日子
中企无忧:http://www.zq5u.com