|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP最大的缺点在于网络的安全性和可靠性,企业将经营数据放在开放的平台上,最大的担忧就是如何保证这些数据不被其他人破坏。把持|页面|源代码 我们在制造网站时一般想设置用户上岸体系,也就是说当用户上岸以后能够看到响应的内容,这类办法被常常利用了,详细的完成的流程图:
详细ASP源代码以下:(包含3个文件)
login.asp
<%@Language="vbscript"%>
<%OptionExplicit%>
<%Response.Buffer=True%>
<!--#includefile="dbConn.asp"-->
<%
================================================
Wastheformsubmitted?
Ifso,letschecktheUsernameandPassword
================================================
IfRequest.Form("Submitted")="login"Then
Declareourvariables
DimobjConn,objRS,strSQL
CreateConnectionObject
SetobjConn=Server.CreateObject("ADODB.Connection")
objConn.OpenstrConnect
BuildSQLString
strSQL="SELECT*FROMMemberInfoWHEREUsername="&Request.Form("Username")&""
CreateRecordsetObject
SetobjRS=Server.CreateObject("ADODB.Recordset")
objRS.OpenstrSQL,objConn
IfobjRS.EOFThen
================================================
DoestheUsernameexist?
Ifnot,setstrFailedanddestroyallobjects.
Wellthendisplaytheloginformagain.
================================================
strFailed="InvalidUsername"
objRS.Close
SetobjRS=Nothing
objConn.Close
SetobjConn=Nothing
Else
================================================
Usernameexists-isthepasswordcorrect?
Ifnot,setstrFailedanddestroyallobjects.
Wellthendisplaytheloginformagain.
================================================
IfobjRS.Fields("Password")Request.Form("Password")Then
strFailed="InvalidPassword"
objRs.Close
SetobjRS=Nothing
objConn.Close
SetobjConn=Nothing
Else
================================================
Usernameandpasswordarevalid.
Setsessionvariable.
Destroyallobjects.
Redirecttosecretpage
================================================
Session("ValidUser")="true"
objRS.Close
SetobjRS=Nothing
objConn.Close
SetobjConn=Nothing
Response.Redirect"secret-page.asp"
EndIf
EndIf
EndIf
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<htmllang="en">
<head>
<title>会员上岸体系</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
</head>
<body>
<h1>LoginArea</h1><%
IfstrFailed""Then
Response.Write"<p>"&strFailed&"</p>"&vbCrLf
EndIf
%><formmethod="post"action="login.asp">
<p>
<labelfor="username">用户名:</label>>
<inputtype="text"id="usernamename="username">
</p>
<p>
<labelfor="password">暗码:</label>
<inputtype="password"id="password"name="password">
</p>
<p>
<inputtype="submit"name="Submitted"value="login">
</p>
</form>
</body>
</html>
dbConn.asp
<%
Declareourvariables
DimstrDBVirtualPath,strDBLocation,strConnect
strDBVirtualPath="memberDB/LoginInfo.mdb"
strDBLocation=Server.MapPath(strDBVirtualPath)
strConnect="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&strDBLocation
Response.WriteChr(13)
%>
secret-page.asp
<%@Language="vbscript"%>
<%OptionExplicit%>
<%Response.Buffer=True%>
<%
=====================================
IstheSessionvariable"ValidUser"
setto"true"?-Ifnot,redirectto
login.asp
=====================================
IfSession("ValidUser")"true"Then
Response.Redirect"login.asp"
EndIf
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<htmllang="en">
<head>
<title>SecretArea</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
</head>
<body>
<h1>SecretArea</h1>
<p>
Welcometothissecretarea.
</p>
</body>
</html>
减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。 |
|