您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

一 些 ASP 小 源 程 序

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 22:25 点击:
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" & ""

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • WAP常见问题问答大全(四)
      • ASP开发必备:WEB打印代码大全
      • ASP调用系统ping命令
      • asp缓存技术
      • ASP教程:第三篇 ASP基础
      • 用ASP+XML打造留言本(4)
      • 关于ASP Recordset 分页出现负数解决方法及建议
      • 用asp怎样编写文档搜索页面(5)
      • ASP处理多关键词查询实例代码
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1