当前位置:编程学习 > C#/ASP.NET >>

我是新手,请解答

各位师兄,小弟才学,请解释下面代码的意义,与数据库是如何连接并如何认证身份的,谢谢



<script language="JavaScript">
if (window != window.top) window.top.location = window.location;
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户登录</title>
<style type="text/css">
<!--
body,td,th { 
  margin-left: 0px;
margin-top: 0px;
font-size: 12px;
}
-->
</style>
<link href="css/newcss.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
function checkData (frm)
{
    with (frm)
    {
        if (account.value == "" || password.value == "")
        {
            alert ("请输入用户名、密码。");
            account.focus ();
            return false;
        }
    }
    return true;
}
</script>
</head>

<body onLoad="data.account.focus ();">
<table width="777" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="images/top2.gif" width="777" height="93"></td>
  </tr>
  <tr>
    <td height="51" align="right" valign="top" bgcolor="#EBF0F6"><table  width="777" height="53" border="0" cellpadding="0" cellspacing="0" background="images/no1.gif">
      <tr>
        <td> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="400" valign="top" bgcolor="#EBF0F6"><table width="90%" border="0" align="center" cellpadding="10" cellspacing="0">
      <tr>
        <td height="40"><p align="center" class="blue12"><img src="images/qing.gif" width="201" height="30"></p></td>
      </tr>
    </table>            <table width="60%" border=0 align="center" cellpadding=1 cellspacing=0 
                        bgcolor=#cc6600>
      <tbody>
        <tr>
          <td scope=col>
            <table cellspacing=0 cellpadding=12 width="100%" 
                              border=0>
              <tbody>
                <tr>
                  
                <td scope=col bgcolor=#fffff0> 
                  <table cellspacing=0 cellpadding=5 width="100%" 
                                border=0>
                    <tbody> 
                    <form name=data method=post onSubmit="return checkData(this);">
                      
                      <tr> 
                        <td width="6%" valign=top scope=col> </td>
                        <td width="35%" align=right scope=col> 用户名: </td>
                        <td width="52%" scope=col>
                          <input type=text name=account maxlength=50 style="width:120">
                        </td>
                        <td width="7%" align=middle scope=col> </td>
                      </tr>
                      <tr> 
                        <td valign=top scope=col> </td>
                        <td align=right scope=col> 密  码: </td>
                        <td scope=col>
                          <input type=password name=password style="font-family:宋体; width:120" maxlength=50>
                        </td>
                        <td scope=col align=middle> </td>
                      </tr>
                      <tr> 
                        <td valign=top scope=col> </td>
                        <td colspan="2" align=center scope=col>
                          <input type="submit" value=" 登  录 " name="submit">
                            
                          <input type="button" value="注册帐户" onClick="window.location='register.jsp';" name="button">
                        </td>
                        <td scope=col align=middle> </td>
                      </tr>
                    </form>
                    </tbody> 
                  </table>
                </td>
                </tr>
              </tbody>
          </table></td>
        </tr>
      </tbody>
    </table>      
      </td>
  </tr>
</table>
</body>
</html>
--------------------编程问答-------------------- 没看到数据连接,只用JAVASCRIPT做了验证用户名及口令不能为空。 --------------------编程问答-------------------- 你可真懒,贴个代码要解释,是不是解释每一行呀,自已先看,关链的才问. --------------------编程问答-------------------- 搞这么多html干什么?
这是前台,验证要后台才行啊。
给你一个后台代码自己研究。


string muser = Convert.ToString(Request.Form["TextBox1"]);
string mpass = Convert.ToString(Request.Form["TextBox2"]);
OleDbConnection myConn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("/App_Data/xxx.mdb"));
            String strSQL = "SELECT * FROM [adm_user] WHERE admin_user='" + muser + "' and admin_pass='" + mpass + "' ";
            OleDbDataAdapter objCmd = new OleDbDataAdapter(strSQL, myConn);
            DataSet ds = new DataSet();
            objCmd.Fill(ds, "adm_user");
            if (ds.Tables["adm_user"].Rows.Count == 0)
                Label1.Text = "用户名或者密码错误!";
            else
            {
//登录成功
                Session["admin_user"] = muser;
                Response.Redirect("admin.htm");
            } --------------------编程问答-------------------- up --------------------编程问答-------------------- 多看书 --------------------编程问答-------------------- 晕!~同意楼上,看点书的话,就会很清楚了!
看代码还真不知道怎么解释好! --------------------编程问答-------------------- 没有与数据库连接,也没有验证,只判断了输入是否为空 --------------------编程问答-------------------- 谢谢以上各位师兄的解释,请问点击登陆后执行了什么代码 --------------------编程问答-------------------- https://login.taobao.com/auction/fast_buy_item.htm?auction_id=31a461e3c895f83d183544965e881ecb&x_id=null&key=38b1a7b20b6420eb43602912979c4f53
很好的验证哦 --------------------编程问答-------------------- 点击登陆后执行了这里:
function   checkData   (frm) 

        with   (frm) 
        { 
                if   (account.value   ==   " "   ¦ ¦   password.value ==   " ") 
                { 
                        alert   ( "请输入用户名、密码。 "); 
                        account.focus   (); 
                        return   false; 
                } 
        } 
        return   true; 

补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,