zoukankan      html  css  js  c++  java
  • WebForm 登陆test

        <script>
            window.onload = function () {
                document.getElementById("form1").onsubmit = function () {
                    var userName = document.getElementById("username").value;
                    var passWord = document.getElementById("pwd").value;
                    if (userName != "" && passWord != "") {
                        return true;
                    } else {
                        alert("用户名和密码不能为空!!!");
                        return false;
                    }
                }
            }
    </script>
    
            string UserName = context.Request["username"];
            string PassWord = context.Request["pwd"];
      //连接数据库
                SqlConnection con = new SqlConnection("server=.;database=test;uid=sa;pwd=123321");
                //执行sql语句
                 string sql = "select count(*) from users where username=@UserName and pwd= @PassWord";
                //string sql = "select * from users";
                SqlCommand cmd = new SqlCommand(sql,con);
                cmd.Parameters.AddWithValue("@UserName",UserName);
                cmd.Parameters.AddWithValue("@PassWord",PassWord);
                con.Open();
                int i = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
                if (i==1)
                {
                    context.Response.Write("登录成功!!!");
                }
                else
                {
                    context.Response.Write("用户名或密码错误!!");
                }
  • 相关阅读:
    CF547D Mike and Fish
    CF147B Smile House
    [BJOI2017]树的难题
    AT2306 Rearranging
    复利计算器--单元测试
    操作系统 实验1 命令解释程序的编写
    个人项目耗时对比记录表
    复利计算器3.0
    0320记《构建之法》读后感
    复利计算实验总结
  • 原文地址:https://www.cnblogs.com/enych/p/8257104.html
Copyright © 2011-2022 走看看