.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> JavaScript/VBScript >> Post New QuestionBookmark and Share Subscribe to Forum

ASP and HTML Form code to store User name and Password in the Access database and Retriew it

Posted By: Sushil     Posted Date: February 13, 2010    Points:2   Category :JavaScript/VBScript
I want simple ASP and HTML Form code to store User name and Password in the Access database and Retriew it

Author: Amit Mehra             
Posted Date: February 13, 2010     Points: 5   

Hi Sushil,

are you asking about classical ASP or Asp.net?

Please "Mark As Answer " if this post help you.
Author: Sushil             
Posted Date: February 13, 2010     Points: 5   

Classical ASP

Author: Sushil             
Posted Date: February 13, 2010     Points: 5   

I have Created Insert Records code but when i click on submit button then FileDownload dialog box displays
plz help me Sir.

Author: Amit Mehra             
Posted Date: February 14, 2010     Points: 5   

hi Sushil,

Sorry I do not have experience in classical asp. I guess this article will help you


Please "Mark As Answer " if this post help you.
Author: Lalij Mer             
Posted Date: February 14, 2010     Points: 5   

Try this code sample



<body bgcolor="#003366">
'StudentNo Of Logged in user
Dim Username
'Retrieving Username
'Invalid Username password
if UserName <> "" then
Response.Write "<font color='#FFAA00'>"
Response.Write "<font face='Verdana' size=2>"
Response.Write"Invalid UserName Password. Please Re-login"
Response.Write "</font></font>"
end if
<form method="POST" action="verify.asp">
<table border="1" cellspacing="1" bordercolor="#111111" id="AutoNumber1" height="82">
<td height="23"><font color="#FFFFFF" face="Verdana" size="2">Student Number</font></td>
<td width="148" height="23">
<p align="center">
<font face="Verdana" color="#FFFFFF">
<input type="text" name="username" size="20" value=""><font size="2">
<td height="22"><font color="#FFFFFF" face="Verdana" size="2">Password</font></td>
<td width="148" height="22">
<p align="center"><font color="#FFFFFF" face="Verdana"><input type="password" name="password" size="20"></font></td>
<td width="210" colspan="2" height="22">
<p align="center"><font face="Verdana"><font color="#FFFFFF">
<input type="checkbox" name="rememberme" value="ON"></font><font size="2" color="#FFFFFF">Remember
<td width="210" colspan="2" height="22">
<p align="center"><font face="Verdana" color="#FFFFFF"><input type="submit" value="LogIn" name="B1"><font size="2">&nbsp;</font><input type="button" value="New User" name="B2" onClick = "location.href('signup.asp');"></font></td>

ASP Code

<body bgcolor="#003366">

'Connection String
Dim Conn
'Query to be executed
Dim SQLQuery
Dim rs
'StudentNo Of Logged in user
Dim UserName
'Password of User
Dim Password

'Getting information from submitted form
UserName = request.form("username")
Password = request.form("password")
RememberMe = request.form("rememberme")

'If not blank Username password submitted
if UserName <> "" or Password <> "" then
'Creating connection Object
set Conn=server.createobject("ADODB.Connection")
'Creating Recordset Object
set rs = Server.CreateObject("ADODB.Recordset")
'Initialising Provider String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source="
connStr = connStr + server.MapPath("Studentrecords.mdb")

'Opening Connection to Database
Conn.open connStr

'Query to be executed
SQLQuery = "select * from tblStudent where StudentNo = '"&UserName&"' AND Password = '"&Password&"'"

'Retrieving recordset by executing SQL
set rs=Conn.execute(SQLQuery)
'If no records retrieved
if rs.BOF and rs.EOF then
Response.Redirect "login.asp?username=" & UserName
'If remember me selected
if RememberMe = "ON" then
'Writing cookies permanently
Response.Cookies("UserName").Expires = Now() + 365
Response.Cookies("Password").Expires = Now() + 365
Response.Redirect "welcome.asp"
'writing cookies temporarily
Response.Redirect "welcome.asp"
end if
'Closing all database connections
set rs = nothing
set Conn = nothing
end if
'Invalid User
Response.Redirect "login.asp?UserName=blank"
end if

Please Check my answer if you help....
Thank You...


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend