Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: ASP Security Login page in ASP through Access DB Tutorial

You will find here a sample script showing you how you can protect a reserved area of your website with a simple login page. The script is using an access sample database.

Tutorial Details:

Application ASP

Techniques / Application ASP

How to protect a site by a password and a login

In the majority of the Web applications, there is today a reserved access protected by a password and a login. This authentification can allow for example the possibility to the user authenticated to download documents, or to have the possibility of poster of information on a forum.

There are several methods to arrive at this result. We will leave on simple bases, to be able to authenticate a user we will need a form where this one will inform are login and its password.

The page containing the form will be "login.asp" and it will be sent it even the data of the form.

After having to recover those we will use a Access base in order to check that the couple login/password is quite existing. If the user does not exist or if its password does not correspond it will not have the right of access and we will post an error message. If not we will be able to redirect it towards the part protected from the site or to post the information to him which we want hidden with the unknown ones.

In the example according to a data base named "login.mdb" is created. It has the table "users" of which here description:

id_user
name
login
password

<%
'Login.asp web page

'Declaration of variables
Dim Con
Dim rstLogin
Dim strSQL

Dim login
Dim password

'If the webpage receive vars from the form:
login = Replace(Request.Form("login"), "'", "''")
password = Replace(Request.Form("password"), "'", "''")

%>
<html>
<head><title>Login Page</title>
</head>
<body bgcolor="gray">
<%

'If this page don't receive var posted by the form
If Request.Form("validate") <> "GO" Then
%>
<form action="login.asp" method="post">
<table border="0">
<tr>
<td align="right">Login:</td>
<td><input type="text" name="login"></td>
</tr>
<tr>
<td align="right">Password:</td>
<td>
<input type="password" name="password">
</td>
</tr>
<tr>
<td align="right"></TD>
<td>
<input name='validate' type="submit" VALUE="GO">
</td>
</tr>
</table>
</form>
<%
Else
sql = "SELECT * FROM users " _
& "WHERE login = '" & login & "' " _
& "AND password ='" & password & "';"

Set Con = Server.CreateObject("ADODB.Connection")
Con.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("login.mdb"))

Set rstLogin = Con.Execute(sql)

If Not rstLogin.EOF Then

'here we can redirect the authentified user
Response.redirect "secure_page.asp"

Else
%>
<p>
<font size="4" face="arial,helvetica"><b>

Logion error !
</b></font>
</p>
<p>
<a href="login.asp">Réessayer</a>
</p>
<%

'we stop here the page
Response.End
End If

' Clean Up
rstLogin.Close
Set rstLogin = Nothing
cnnLogin.Close
Set cnnLogin = Nothing
End If
%>
</body>
</html>


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
ASP Security Login page in ASP through Access DB Tutorial

View Tutorial:
ASP Security Login page in ASP through Access DB Tutorial

Related Tutorials:

Secure a Web application, Java-style - JavaWorld April 2000
Secure a Web application, Java-style - JavaWorld April 2000
 
Use Microsoft's Internet Information Server as a Java servlet engine - JavaWorld June 2000
Use Microsoft's Internet Information Server as a Java servlet engine - JavaWorld June 2000
 
Integrate security infrastructures with JBossSX
Integrate security infrastructures with JBossSX
 
Java security evolution and concepts, Part 4
Java security evolution and concepts, Part 4
 
Publish
Publish event-driven Web content with JSP custom tags
 
Rumble in the jungle: J2EE versus .Net, Part 2
Rumble in the jungle: J2EE versus .Net, Part 2
 
All that JAAS
All that JAAS
 
Develop Java portlets
Develop Java portlets
 
JavaServer Faces, redux
JavaServer Faces, redux
 
Java and Security, Part 1
Java and Security WebLogic provides a comprehensive suite of security services that can be used to protect all aspects of a domain and its deployments. These security services affect all aspects of your domain: from the lowest level provided by the Jav
 
Jeff Schmitt's JDBC Page
This tutorial assumes you are using the MySQL database and the GWE JDBC drivers. The host computer is triton.towson.edu.
 
Building Java Server Pages
A detailed look at building JSP pages. Should you use JSP or servlets? It mainly depends on the ratio of markup to code. Here you'll also find a guide to the different varieties of tag, and details about the main tags such as and  

Free Web Site Hosting Services Below is the listing of the hosting providers providing free web hosting services. These services helps you building your sites even if you have no experience in HTML writing. Zero
 

Linux Hosting Plans Proxima Web-Hosting Our basic hosting packages include support for a wide variety of web technologies, backed by instant account management with our Personal Control panel. With our guaranteed
 
JSP FUNDAMENTALS
JSP FUNDAMENTALS JSP FUNDAMENTALS By: Hrishikesh Deshpande Introduction : JSP termed as Java Server Pages is a technology introduced by Sun Microsystems Inc. to develop the web application in more efficient way than Servlets. It has got many
 
Struts Guide
Struts Guide Struts Guide This tutorial is extensive guide to the Struts Framework. In this tutorial you will learn how to develop robust application using Jakarta Struts Framework. This tutorial assumes that the reader is familiar with the web
 
What is Web Hosting
What is Web Hosting What is Web Hosting? What is Web Hosting? If you have a company and want web presence than you need a website. With the website any one from the world must be able to view your pages, images etc. Website is actually a
 
A Practical Roadmap for Deploying Enterprise Web Applications: Taking the First Step
This article covers important decision points around the availability, scalability, and security that are needed for enterprise web applications.
 
JavaServer Faces in Action, Chapter 8
Shows how to build a static Login page with JavaServer Faces and JSP technology by importing the proper tag libraries, and adding HtmlGraphicImage and HtmlOutputText components.
 
Integrating Java Open Single Sign-On in Pluto
This article shows how to integrate Java Open Single Sign-On in Apache\'s Pluto portlet container.
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.