一 些 ASP 小 源 程 序
程序员文章站
2022-07-07 19:39:29
active server pages password script <%sub...
active server pages
password script
<%
sub forminput() %>
<form method=post action="logon.">
<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" & ""
password script
<%
sub forminput() %>
<form method=post action="logon.">
<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" & ""
上一篇: 一个免费的邮件列表源程序(二)
下一篇: 用密码保护页面 (III)