Generic Logon

User Name:
论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > asp教程
Tag:入门,文摘,实例,技巧,iis,表单,对象,上传,数据库,记录集,session,cookies,存储过程,注入,分页,安全,优化,xmlhttp,fso,jmail,application,防盗链,stream,组件,md5,乱码,缓存,加密,验证码,算法,ubb,正则表达式,水印,,日志,压缩,url重写,控件,函数,破解,触发器,socket,ADO,初学,聊天室,留言本,视频教程

一 些 ASP 小 源 程 序

文章类别:asp | 发表日期:2008-10-5 20:43:08

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 = "" & "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 & "<BR>"
Next
%>  

视频教程列表
文章教程搜索
 
Asp推荐教程
Asp热门教程