|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。ActiveServerPages
PasswordScript
<%
SubFormInput()%>
<formmethod=postaction="logon.asp">
<center>
<H1>GenericLogon</H1>
UserName:<inputtype=textsize=20name=username>
<br><br>
Password:<inputtype=passwordsize=20name=password>
<br><br>
<inputtype=submitname=submitvalue="Submit">
</center>
</form>
<%EndSub%>
<!--#includefile="adovbs.inc"-->
<%
***********PasswordLoginCode*********************
***********programmedbyRobertRobbins************
***********FirstVersion03/28/99******************
*****************************************************
CallInputFormsubroutine
FormInput()
Createsessionvariable.Usernameneededforfilename.asp
Session("user")=""
Initializebooleanflagstofalse
correct_name=False
correct_password=False
Connecttotableindatabase
Setcn=Server.CreateObject("ADODB.Connection")
Setrs=Server.CreateObject("ADODB.Recordset")
cn.Open"DSNName"
rs.Open"Select*FromTableName",cn,adOpenStatic,adLockPessimistic
Testforcorrectusernameandpassword
IfRequest.Form("submit")>""Then
DoWhileNotrs.EOF
Compareforminputtopassworddatabaserecordsetvalues
IfRequest.Form("username")=rs("username")Then
correct_name=True
EndIf
IfRequest.Form("password")=rs("password")Then
correct_password=True
EndIf
rs.MoveNext
Loop
Ifcorrect_password=TrueAndcorrect_name=TrueThen
Ifpasswordandusernamearecorrect,jumptoDataEntry.asp
Note:chr(34)isthedoublequotescharacter
Session("user")=Request.Form("username")
Response.write"<ScriptLanguage="&chr(34)&"JavaScript"&chr(34)&">"
Response.write"window.location="&chr(34)&"DataEntry.asp"&chr(34)&"""
Response.write"</Script>"
Else
Ifpasswordorusernameisincorrect,writeJavaScriptcodeinHTMLforanalert
dialogbox
Response.write"<ScriptLanguage="&chr(34)&"JavaScript"&chr(34)&">"
Response.write"alert("&chr(34)&"AccessDenied!"&chr(34)&");"
Response.write"</Script>"
EndIf
rs.Close
EndIf
%>
PasswordProtectScript
<%
SetlocalvariableusernametoSessionvariableuser
username=Session("user")
Ifusernameisanemptystring,theuserdidnotuselogon.asptologin
Ifusername=""Then
Response.write"Sorry,youarenotloggedin!<br>"
Session.Abandon
Response.End
EndIf
%>
EmailScript
Newline=chr(13)&chr(10)
SetMailer=Server.CreateObject("CDONTS.NewMail")
Mailer.To=""&Request.Form("Email")&""
Mailer.From=""&"rrobbins@sunlink.net"&""
Mailer.Subject=""&"TestingAutomatedEmail"&""
Mailer.Body=""&"Myemailmessage"&Newline&"Secondline"&""
Mailer.Send
SetMailer=Nothing
SQLServerConnection
<%
Setcn=Server.CreateObject("ADODB.Connection")
Setrs=Server.CreateObject("ADODB.Recordset")
strConn="driver={SQLServer};server=Pentium;uid=sa;pwd=;database=Test"
cn.OpenstrConn
%>
WindowsScriptHost
WindowsScriptHostFile
programmedbyRobertS.Robbins
Opendatabaseconnecectionandgetrecordset
ConstadOpenForwardOnly=0
ConstadLockPessimistic=2
Setcn=WScript.CreateObject("ADODB.Connection")
Setrs=WScript.CreateObject("ADODB.Recordset")
cn.Open"DSNName"
rs.Open"Select*FromTableName",cn,adOpenForwardOnly,adLockPessimistic
WhileNotrs.EOF
message=rs("Message")
MsgBoxmessage,64,"DatabaseMessage"
rs.MoveNext
Wend
VBScript5.0RegularExpression
<%
SetobjFile=Server.CreateObject("Scripting.FileSystemObject")
SetinFile=objFile.OpenTextFile("D:Temp est.txt",1)
strInput=inFile.ReadALL
inFile.Close
SetmyTest=newRegExp
myTest.Pattern="w+,"
myTest.Global=True
myTest.IgnoreCase=True
SetmyCollection=myTest.Execute(strInput)
ForEachelementInmyCollection
Response.writeelement&"<BR>"
Next
%>
楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。 |
|