ASP教程:制作登陆页面验证程序代码
本程序的作用是防止非认证用户访问指定页面。一下是相关文件代码。
利用程序来进行密码验证,这种方法较为通用,它对Web服务器没有具体要求,它是借助数据库及ASP程序进行设计,来实现一种通用网页加密。
首先,我们利用Microsoft Access建立“用户名称及密码”的数据表,假设将这个表取名为User,数据库名为Usercheck.mdb,数据表的结构如下:
字段说明 字段名称 数据类型 数据长度
用户名称 ID 文本 15
密码 PWD 文本 15
验证程序PASS.ASP的源代码如下:
| <% Function Check( ID, Pwd ) Dim conn, par, rs Set conn = Server.CreateObject("ADODB.Connection") par = "driver={Microsoft Access Driver (*.mdb)} " conn.Open par && ";dbq=" && Server.MapPath("usercheck.mdb ") sql = "Select * From users Where ID= && ID && And Pwd = && Pwd &&" Set rs = conn.Execute( sql ) If rs.EOF Then Check= False Else Check= True End If End Function %> <% If IsEmpty(Session("Passed")) Then Session("Passed") = False Head = "请输入用户名和密码" ID = Request("ID") Pwd = Request("Pwd") If ID = "" Or Pwd = "" Then Head = "请输入用户名和密码" Else If Not Check( ID, Pwd ) Then Head = "用户名称或密码有错" Else Session("Passed") = True End If If Not Session("Passed") Then %> <html> <head><title></title></head> <body BGCOLOR="#FFFFFF"> <h2 ALIGN="CENTER"><%=Head%></h2> <hr WIDTH="100%"> <form Action="<%=Request.ServerVariables("PATH_INFO")%>" Method="POST"> <table BORDER="1" CELLSPACING="0"> <tr> <td ALIGN="RIGHT">用户名称:</td> <td><input Type="Text" Name="ID" Size="12" Value="<%=ID%>"></td> </tr> <tr><td ALIGN="RIGHT">密码:</td> <td><input Type="Password" Name="Pwd" Size="12" Value="<%=Pwd%>"></td></tr> </table> <p><input Type="Submit" Value="确定"></p> </form> <hr WIDTH="100%" align="center"> </body> </html> <%Response.End End If%> |
这个验证合法性的页面具有通用性,只要在需要加密网页的最前面加上如下程序:
| <!–#include file="pass.asp"–> |
即可实现对任意网页进行加密的功能了。
72 responses to "ASP教程:制作登陆页面验证程序代码"
3:13 on 九月 27th, 2011
I don’t often reply to posts however I will in this case.
9:29 on 九月 27th, 2011
Carry on running a blog! its getting via the robust instances that make you more potent after which the good instances will comply with, preserve writing about your studies and we will have to all pull together.
14:38 on 九月 29th, 2011
Try and strive, that is the key to success, giving up shouldn’t be integrated on our dictionary (i believe).
9:26 on 九月 30th, 2011
Very attention-grabbing… as always! Cheers from Switzerland.
7:56 on 十月 3rd, 2011
The current financial local weather forces all marketers to paintings harder whether or not thats face to face promoting or advertising your website online.
1:02 on 十月 4th, 2011
Now more that ever you in all probability’t have enough money to just take a seat again as your opponents almost definitely working time beyond to make as much money as they have been pre-recession.
1:58 on 十月 6th, 2011
Howdy very good blog!!
8:39 on 十月 7th, 2011
All the things you stated is right, however so much upsides. Like, you can’t be fired.
4:29 on 十月 10th, 2011
Thank you a lot for this data … I’m already doing some of these options however a lot of others that are new to me.
5:56 on 十月 12th, 2011
ohhh good data
14:02 on 十月 13th, 2011
That’s Too nice, while it is to be had india desire it would possibly make a Rocking position for youngster.. hope that come true.
12:46 on 十月 14th, 2011
Good post! GA can also my largest earning. Nevertheless, it’s now not a much.:)
12:02 on 十月 17th, 2011
I’ve simply started a small search engine optimisation consultancy enterprise and the steady income thing just not a major fear for me, as I have a number shoppers who pay in monthly installments. The only thing that I find arduous is realizing when to stop paintings and when I can actually begin it. I’ve a young household so time is a major difficulty for me.
13:18 on 十月 18th, 2011
Do you do all your individual writing? Or do you outsource a few of it? I’m searching for a few comparable content material for my blog! These are nice posts!
7:50 on 十月 19th, 2011
Im just getting started down this highway, the journey is going to be long, but my goal is two years to have an entire time revenue online and to give you the chance spend more time with my household as a substitute of going for a nine to 5 job..
13:19 on 十月 21st, 2011
Great info for rookies to decide which affiliate gives to promote to make most profits. I all the time be taught loads from your posts. Thanks.
9:05 on 十月 24th, 2011
In trying to find websites related to website hosting and particularly comparison internet hosting linux plan net, your web site came up.
23:13 on 十月 24th, 2011
Feels like a great idea. must have tons of subscriber occur to do that.
7:57 on 十月 26th, 2011
Super-Duper web site! I’m loving it!! Will come again again – taking you feeds also, Thanks.
1:47 on 十月 27th, 2011
When I don’t have an thought to blog, I cleanup my folders in my PC and do defragmentation in my device…
6:21 on 十月 30th, 2011
A few years ago I’d have to pay someone for this informiaotn.
17:37 on 十月 30th, 2011
NiWEuj vkgolqrcudbn