-
您的位置:首页 → 精文荟萃 → 软件资讯 → 一 些 ASP 小 源 程 序
一 些 ASP 小 源 程 序
时间:2004/10/7 19:18:00来源:本站整理作者:蓝点我要评论(0)
-
Active Server Pages
Password Script
<%
Sub FormInput() %>
<% End Sub %>
<%
' *********** Password Login Code *********************
' *********** programmed by Robert Robbins ************
' *********** First Version 03/28/99 ******************
' *****************************************************
' Call Input Form subroutine
FormInput()
' Create session variable. Username needed for filename.asp
Session("user") = ""
' Initialize boolean flags to false
correct_name = False
correct_password = False
' Connect to table in database
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.Open "DSN Name"
rs.Open "Select * From TableName",cn,adOpenStatic,adLockPessimistic
' Test for correct username and password
If Request.Form("submit") > "" Then
Do While Not rs.EOF
' Compare form input to password database recordset values
If Request.Form("username") = rs("username") Then
correct_name = True
End If
If Request.Form("password") = rs("password") Then
correct_password = True
End If
rs.MoveNext
Loop
If correct_password = True And correct_name = True Then
' If password and username are correct, jump to DataEntry.asp
' Note: chr(34) is the double quotes character
Session("user") = Request.Form("username")
Response.write ""
Else
' If password or username is incorrect, write JavaScript code in HTML for an alert
dialog box
Response.write ""
End If
rs.Close
End If
%>
Password Protect Script
<%
' Set local variable username to Session variable user
username = Session("user")
' If username is an empty string, the user did not use logon.asp to login
If username = "" Then
Response.write "Sorry, you are not logged in!
"
Session.Abandon
Response.End
End If
%>
Email Script
Newline = chr(13) & chr(10)
Set Mailer = Server.CreateObject("CDONTS.NewMail")
Mailer.To = "" & Request.Form("Email") & ""
Mailer.From = "" & "rrobbins@sunlink.net" & ""
Mailer.Subject = "" & "Testing Automated Email" & ""
Mailer.Body = "" & "My email message" & Newline & "Second line" & ""
Mailer.Send
Set Mailer = Nothing
SQL Server Connection
<%
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
strConn = "driver={SQL Server};server=Pentium;uid=sa;pwd=;database=Test"
cn.Open strConn
%>
Windows Script Host
' Windows Script Host File
' programmed by Robert S. Robbins
' Open database connecection and get recordset
Const adOpenForwardOnly = 0
Const adLockPessimistic = 2
Set cn = WScript.CreateObject("ADODB.Connection")
Set rs = WScript.CreateObject("ADODB.Recordset")
cn.Open "DSN Name"
rs.Open "Select * From TableName",cn,adOpenForwardOnly,adLockPessimistic
While Not rs.EOF
message = rs("Message")
MsgBox message,64,"Database Message"
rs.MoveNext
Wend
VBScript 5.0 Regular Expression
<%
Set objFile = Server.CreateObject("Scripting.FileSystemObject")
Set inFile = objFile.OpenTextFile("D:\Temp\test.txt", 1)
strInput = inFile.ReadALL
inFile.Close
Set myTest = new RegExp
myTest.Pattern = "\w+,"
myTest.Global = True
myTest.IgnoreCase = True
Set myCollection = myTest.Execute(strInput)
For Each element In myCollection
Response.write element & "
"
Next
%>
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3
最新文章
微信3.6.0测试版更新了微信支付漏洞会造成哪
360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗
人气排行
xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本
查看所有0条评论>>