Microsoft's masterpiece ASP (Active Server Pages) is starting a new Web programming revolution (in the strictest sense, writing ASP is not programming) for its ease of use, scalability, and functionality. It replaces the momentum of CGI (Common Gateway Interface, Universal Gateways), written in Perl and other languages, with astonishing development and speed of popularity. Web page based Web management mode has become the trend, look at the current network managers, who will not be ASP's writing it? Want to manage? Then you might want to use the "Password verification" I'm going to say. Simply put, password verification is the first to determine whether you have login rights, if there is, continue, otherwise, hem ... What the? You still do not know what the ASP is Dongdong? "The program has performed an illegal operation and is about to be closed." If you still have a problem, contact the program vendor. "----------System language
Let's take a look at what the ASP needs to implement password validation.
ASP operating Environment:
Windows 95/98 stand-alone platform: PWS (Personal Web Server) 4.0, Windows NT 4.0/5.0 server platform: IIS (Internet Information Server) Service Pack 3 and its Version above)
NT Workstation 4.0 Workstation platform: PWS (Personal Web Server) NT Workstation version and the latest version of IE browser.
Second, for the production of ASP software
Windows FrontPage 98/2000, Dreamweaver 3.0, if you don't have the software, use Notepad in Windows to be a "code-writer Maniac". However, many of the code in the ASP still need us to write a large number of code, using a dedicated web page to make software is just a little lazy to steal.
What kind of database do you use as a database for storing user information (username and password)?
SQL Server, Microsoft Access 97/2000, and so on are all available. I suggest you use access because you might be familiar with it, and if you have a problem, it's easier to fix it, and the deeper reason is that Microsoft access is more efficient than other non server-level databases.
Well, the nonsense has said so much that you may have been impatient already. However, this may be helpful for some ASP beginners, for this part of the reader, you may have to look at the ASP book or Web site to increase your understanding of ASP basic syntax.
Let's do this password verification step-by-step, I am using Windows 4.0 + PWS platform, IE 5.0 browser, web production software: FrontPage 2000. Go!
First, create a user password database
First use access to create a user password database, create a field name ID and PSD, and add values. For example: ID value I set to: ADMIN,PSD value: www, of course, you can continue to add User ID and PSD, after the completion of the Save as: Psd.mdb.
Second, the preparation of psd.asp (User login Interface page, complete the validation of the hero is it) and log.asp (successful login after the display of the page). Before writing, let's analyze the common user login interface, for example, you want to charge a Web page way free mail Box login interface: Manage user login file name is often log.*, start login is this file, login completed after the browser's address bar or the display of this file name, What the hell is going on here? In terms of ASP, it turns out that the user logged in file is included in the file after the login is completed. For the example I'm going to talk about, Psd.asp is included in the log.asp. The file name that users see when they log on is: log.asp, and log.asp requires the system to perform psd.asp first and then see the real log.asp page after verification. That's right! In fact, the key to password verification is psd.asp. After you have finished reading this article, you will understand it deeply. Since psd.asp files are the key, let's take a look at how psd.asp is written.
Run FrontPage to create a new file and save it as: psd.asp (select Active Server Pages in the Save type in FrontPage). In the lower left corner of FrontPage, select HTML to write the ASP source code at the top of it, as follows (all of the following source code appears as "' ..." in all comments):
<%
function checkpwd (ID,PSD) ' detects user ID and password
Dim conn,param,rs
Set Conn=server.createobject ("Adodb.connection") ' Creates a database connection object conn
param= "Driver={microsoft Access Driver (*.mdb)}" ' Specifies the database driver, not to be omitted write as "Access Diver (*.mdb)"
Conn.Open param & ";d bq=" & Server.MapPath ("Psd.mdb") ' opens the database with the specified database driver and specifies the data path
Sql= "Select*from psd where id= '" & ID & "' and Psd= '" & PSD & "'" Defines SQL reading ID and PSD values from the database, the first PSD in the bank is the database name to The rear PSD refers to the PSD field in the Psd.mdb.
Set Rs=conn.execute (SQL) ' Open database
If Rs.eof Then
Checkpwd=false
Else
Checkpwd=true
End If
End Function ' The above sentence to determine whether you have read the records in the database, if not, read backwards, if completed, verify the user name and password. True if validation is passed, otherwise flase
%>
<%
If IsEmpty ("passed") then session ("passed") =false ' judge user input information
Id=request ("id") ' Get user ID (user name)
Psd=request ("psd") ' Get user psd (password)
If id= "" or psd= "" Then
Response.Write "Please enter your login name and password." "' If the user does not enter complete information, return an error message.
ElseIf not Checkpwd (ID,PSD) Then
Response.Write "Username or password is wrong! <br> Please check your username and password and try again! "' If the user has entered the full information, but the input error also returns an error message.
else session ("passed") =true
End If
If not session ("passed") then%> ' the information entered by the user is completely correct and validated, the following starts with the HTML code to make a user login interface.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.