一款经典的ajax登录页面 后台asp.net(9)

    protected void Page_Load(object sender, EventArgs e)
    {
        OleDbConnection Conn 
= DBcon.get_con();

        
if (Request["uname"!= null)
        {
            
string username = Request["uname"].ToString();
            
string strSql = "select * from [user] where u_name='" + username + "'";
            Conn.Open();
            OleDbCommand Comd 
= new OleDbCommand(strSql, Conn);
            OleDbDataReader dr 
= Comd.ExecuteReader();
            
if (dr.Read())
            {
                Response.Write(
"ok\n");
            }
            
else
            {
                Response.Write(
"fail\n");
            }
            
//if (Comd.ExecuteNonQuery() > 0)
            
//{
            
//    Response.Write("存在这个用户\n");
            
//}
            
//else
            
//{
            
//    Response.Write("没有此用户名\n");
            
//}
            Conn.Close();
        }

        
if (Request["name"!= null && Request["pwd"!= null)
        {
            
string name = Request["name"].ToString();
            
string pwd = Request["pwd"].ToString();
            
string strSql = "select * from [user] where u_name='" + name + "'" + " and u_pwd='" + pwd + "'";
            Conn.Open();
            OleDbCommand Comd 
= new OleDbCommand(strSql, Conn);
            OleDbDataReader dr 
= Comd.ExecuteReader();
            
if (dr.Read())
            {
                Response.Write(
"ok\n");
            }
            
else
            {
                Response.Write(
"fail\n");
            }
        }
    }


5,新建一名为loginIndex.htm的静态页面,作为用户登录之后的首页


其body标签代码如下


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfwpxj.html