ONLINE NESCAFE OF COLLEGE CAMPUS-10
(DATABASE CONNECTIVITY, CHECKING FROM DATABASE)
verifyadmin.ASP
Whenever you login in any site, first of all, it is checked if the user has ever sign up and the details of the user are present in the database of the system. This is done with the help of the following script:
I have also created a table named admin in STORAGE.MDB in which I have included only the fields of administrator and password as follows:
Here I have also created a session object. It is used to keep something constant for every individual user. Its implementation will be described later.
Response.Redirect is a method usd to open a particular page if the validations are successful. Here, it will open a page called functions of admin.asp which is described later.
<%@LANGUAGE=”VBSCRIPT”%>
<!–#include virtual=”/adovbs.inc”–>
<html>
<head>
</head>
<body>
<center>
<%
Dim admin_name
Dim admin_password
admin_name=Request.Form(“admin_name”)
admin_password=Request.Form(“admin_password”)
Dim objConn,objRS,MPath
MPath=Server.MapPath(“Storage.mdb”)
Set objConn=Server.CreateObject(“ADODB.Connection”)
objConn.Provider=”Microsoft.Jet.OLEDB.4.0″
objConn.Open (MPath)
Dim strSQL
strSQL=”SELECT * FROM Admin WHERE Administrator=’” & admin_name & “‘ AND Password=’” & admin_password &”‘ ”
set objRS=Server.CreateObject(“ADODB.Recordset”)
objRS.OPen strSQL,objConn,1,2
If admin_name=”" OR admin_password=”" Then
response.Write “<br><br><br><font color=’#FF0000′ face=’Verdana, Arial, Helvetica, sans-serif’ size=’+3′>You must fill every detail.<br><br><br>”
Response.Write “<a href=’frame.asp’>Back</a></font>”
ElseIf objRS.RecordCount = 0 Then
response.Write “<br><br><br><font color=’#FF0000′ face=’Verdana, Arial, Helvetica, sans-serif’ size=’+3′>Sorry,Name and Password does not match.<br><br><br>”
Response.Write “<a href=’frame.asp’>Back</a></font>”
Else
Session(“User_Name”) = admin_name
Session(“User_Type”) = 1
Response.Redirect “functions of admin.asp”
End If
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
%>
</center>
</body>
</html>