当前位置: 首页 > 图文教程 > 网络编程 > ASP > 一 些 ASP 小 源 程 序

ASP
实例详解ASP中断开记录集的使用方法
代码指导用ASP木马实现FTP和解压缩
防范脚本入侵,你做好准备了吗?
ASP中检查没有数据提交的页面
ASP程序代码执行时间统计类
ASP实现将长的标题用省略号收尾
ASP常用代码剪辑
在ASP中利用“正则表达式” 对象实现UBB风格的论坛
ASP批量生成静态页
ASP生成柱型体,折线图,饼图源代码
马克斯电影站生成Rss Feed的代码
ASP怎么谈到应用到类的?
ASP:判断访问是否来自搜索引擎的函数
ASP代码:rs.open语句详细说明
用asp自动解析网页中的图片地址
ASP:True or False,明明白白你的If语句流程
ASP实现在提交表单到数据库的同时发邮件通知
“Web 匿名用户”帐户密码的位置
ASP分页效果之优化
使用新云cms过程中的问题总结

一 些 ASP 小 源 程 序


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 47 ::
收藏到网摘: n/a

  Active Server Pages    
Password Script    
<%
Sub FormInput() %>
<form method=post action="logon.asp">
<center>
<H1>Generic Logon</H1>
User Name:<input type=text size=20 name=username>
<br><br>
Password:<input type=password size=20 name=password>
<br><br>
<input type=submit name=submit value="Submit">
</center>
</form>
<% End Sub %>
<!--#include file="adovbs.inc" -->

<%
' *********** 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 "<Script Language=" & chr(34) & "JavaScript" & chr(34) & ">"
Response.write "window.location = " & chr(34) & "DataEntry.asp" & chr(34) & """
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(34) & "JavaScript" & chr(34) & ">"
Response.write "alert(" & chr(34) & "Access Denied!" & chr(34) & ");"
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 an empty string, the user did not use logon.asp to login
If username = "" Then
Response.write "Sorry, you are not logged in!<br>"
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 = "" & "[email protected]" & ""
Mailer.Subject = "" & "Testing Automated Email" & ""
Mailer.Body = "" & "My email message" & Newline & "Second line" &