一 些 ASP 小 源 程 序

2018-09-06 11:19

阅读:514

  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 rs = Server.CreateObject(ADODB.Recordset)
cn.Open DSN Name
rs.Open Select * From TableName,cn,adOpenStatic,adLockPessimistic

Test for correct username and password
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 window.location = chr(34) DataEntry.asp chr(34)

Else
If password or username is incorrect, writeJavaScript code in HTML for an alert
dialog box

Response.write alert( chr(34) access(小型网站之最爱) Denied! chr(34) );

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

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.Subject = Testing Automated Email


评论


亲,登录后才可以留言!