You are on page 1of 4

OUTPUT

Login.asp: <html> <head> <title>Home</title> </head> <body> <center> <% 'StudentNo Of Logged in user Dim Username 'Retrieving Username Username=Request.QueryString("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 %> <center><p>Welcome to my login page</p></center> <form method="POST" action="verify.asp"> <table border="1" cellspacing="1" bordercolor="#111111" id="AutoNumber1" height="82"> <tr> <td height="23"><font color="#111111" face="Verdana" size="2">Student Name</font></td> <td width="148" height="23"> <p align="center"> <font face="Verdana" color="black"> <input type="text" name="username" size="20" value=""><font size="2"> </font></font> </td> </tr> <tr> <td height="22"><font color="black" face="Verdana" size="2">Password</font></td> <td width="148" height="22"> <p align="center"><font color="black" face="Verdana"><input type="password" name="password" size="20"></font></td></tr> <tr> <td width="210" colspan="2" height="22"> <p align="center"><font face="Verdana"><font color="black"> <input type="checkbox" name="rememberme" value="ON"></font><font size="2" color="black">Remember Me</font></font></td>

</tr> <tr> <td width="210" colspan="2" height="22"> <p align="center"><font face="Verdana" color="black"><input type="submit" value="LogIn" name="B1"><font size="2">&nbsp;</font><input type="button" value="New User" name="B2" onClick = "location.href('login.asp');"></font></td> </tr> </table> </form> </center> </div> </body> </html> Verify.asp: <body bgcolor="#003366"> <% 'Connection String Dim Conn 'Query to be executed Dim SQLQuery 'Recordset 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 UserName = '"&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 else 'If remember me selected if RememberMe = "ON" then 'Writing cookies permanently Response.Cookies("UserName")=UserName Response.Cookies("Password")=Password Response.Cookies("UserName").Expires = Now() + 365 Response.Cookies("Password").Expires = Now() + 365 Response.Redirect "welcome.asp" else 'writing cookies temporarily Response.Cookies("UserName")=UserName Response.Cookies("Password")=Password Response.Redirect "welcome.asp" end if 'Closing all database connections Conn.Close rs.close set rs = nothing set Conn = nothing end if else 'Invalid User Response.Redirect "login.asp?UserName=blank" end if %> Welcome.asp <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>welcome to my company</title> </head><body> welcome to my company</body></html>

You might also like