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("用户名或密码错误!!");
                }
  • 相关阅读:
    Add Two Numbers
    Same Tree
    Single Number
    题目1190:大整数排序
    题目1182:统计单词
    题目1181:遍历链表
    题目1180:对称矩阵
    题目1179:阶乘
    题目1206:字符串连接
    HTML事件
  • 原文地址:https://www.cnblogs.com/enych/p/8257104.html
Copyright © 2011-2022 走看看