Using ASP technology to validate user's password in homepage
----know that in a typical Web site, the user's access is unrestricted, that is, any information on the Web site can be accessed, and the order in which the information is accessed is unrestricted.
Take http://www.xyz.com as an example, the user can access the http://www.xyz.comand can access http://www.xyz.com/custom.htm. There is no restriction on the order of the two-page access, that is, you can access the http://www.xyz.com/custom.htmFirst, or you can access http://www.xyx.com.
This flexibility is convenient for average users, but for certain applications, such as web-based e-mail systems such as http://www.hotmail.com, web-based Intranet systems that require user password authentication must limit the order in which users access information. It requires the user to first enter the logon information on the login page and then dynamically generate the corresponding home page based on the user name. This can generally be achieved by two ways to achieve control. One, the CGI way. Second, Java applet or ActiveX front-end way.
This article describes an easy-to-use asp (Active Server Page) method in the CGI approach. Readers who are unfamiliar with ASP can get a preliminary impression by reading the following procedure. The following procedure will give the entire simulation system in a concise manner. Include a SQL Server database users
Username |
Password |
Other |
Char (10) |
Char (10) |
Char (50) |
----and the following homepage: Global.asa (set global variable), check.asp (for calibration), homepage.htm (Login page), homepage1.asp (check through page, with <!--#include file= " Includecheck.asp "--> means including includecheck.asp).
----Global.asa files are as follows:
< SCRIPT language=vbscript Runat=server >
Sub Session_OnStart
Set session ("OBJdbConnection") =server.createobject ("ADODB"). Connection ")
Session ("OBJdbConnection"). Open "DSN=FENG2; Uid=sa; Pwd= "
End Sub
Sub Session_OnEnd
Session (' OBJdbConnection '). Close
End Sub
</script >
Using ASP technology to validate user's password in homepage
homepage.htm files are as follows:
< HTML >
< head >
< meta name= "generator" content= "Microsoft FrontPage 3.0" >
< meta http-equiv= "Content-type" content= "text/html; Charset=gb_2312-80 ">
< title >document title</title >
< BODY >
< p align= "center" > Please enter username and password:<//>
< form method= "POST" action= "check.asp" name= "Checkform" >
< div align= "center" >
< Center >
< p > Username:< input type= "text" name= "username" size= "" ></P >
</center >
</div >
< div align= "center" >< Center >
< p > Password:
< input type= "password" name= "password" size= "></p >
</center >
</div >
< div align= "center" >< Center >
< p >< input type= "submit" value= "confirm" name= "B1" >
< input type= "reset" value= "reset" name= "B2" ></p >
</center ></div >
</form >
</body >
Using ASP technology to validate user's password in homepage
check.asp files are as follows:
%@ language= "VBSCRIPT"%
%
Session ("username") =request.form ("username")
Session ("Password") =request.form ("password")
if (Session ("username") = "") Then
Response.Redirect "Homepage.htm"
End If
sqlquery= "SELECT * from Users WHERE username= '" +session
("username") + "' and Password= '" +session ("password") + "'"
Set list=session ("OBJdbConnection"). Execute (SQLQuery)
if (list.eof and LIST.BOF) then
Session ("username") = ""
Session ("password") = ""
Response.Redirect "Homepage.htm"
End If
% >
< HTML >
< head >
< TITLE > User and Password verification process </title >
< BODY >
You have authenticated through user and password
< P >< a href= "homepage1.asp" > Connect to Next page!</></p >
</body >
Using ASP technology to validate user's password in homepage
homepage1.asp files are as follows:
<!--#INCLUDE file= "includecheck.asp"-->
< HTML >
< head >
< title > Welcome into this system </title >
< BODY >
< p align= "center" > Welcome through the certification into the system! </p >
</body >
includecheck.asp files are as follows:
%@ language= "VBSCRIPT"%
%
' Judge if there is no first access to homepage.htm and then press OK button
If IsEmpty (Session ("username")) or IsEmpty ("password") then
Response.Redirect "Homepage.htm"
End If
' Judge if there's any success with user name and password verification
If session ("username") = "" Then
Response.Redirect "Homepage.htm"
End If
% >