' 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 but 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 ' is the double quotes character
Session ("user") = Request.Form ("username")
Response.Write "<script language=" & Chr (+) & "JavaScript" & Chr (+) & ">"
Response.Write "window.location =" & Chr (+) & "dataentry.asp" & Chr (+) & ""
Response.Write "</Script>"
Else
' If password or username is incorrect, write JavaScript code in HTML for an alert
dialog box
Response.Write "<script language=" & Chr (+) & "JavaScript" & Chr (+) & ">"
Response.Write "Alert (" & CHR) & "Access denied!" & Chr (+) &);
Response.Write "</Script>"
End If
Rs. Close
End If
%>
Password Protect Script
<%
' Set local variable username to session variable user
Username = Session ("User")
' If username is a empty string, the user did not use Logon.asp to login
If username = "" Then
Response.Write "Sorry, are not logged in!<br>"
Session.Abandon
Response.End
End If
%>
Email Script
NewLine = Chr (+) & 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=;d atabase=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 & "<BR>"
Next
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.