ONLINE NESCAFE OF COLLEGE CAMPUS-9
(DATABASE CONNECTIVITY, CHECKING FROM DATABASE)
verifyuser.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:
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 userframe.asp which is described later.
<%@LANGUAGE=”VBSCRIPT”%>
<!–#include virtual=”/adovbs.inc”–>
<html>
<head>
</head>
<body>
<center>
<%
Dim user_name
Dim user_password
user_name=Request.Form(“user_name”)
user_password=Request.Form(“user_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 Students WHERE Username=’” & user_name & “‘ AND Password=’” & user_password &”‘ ”
set objRS=Server.CreateObject(“ADODB.Recordset”)
objRS.OPen strSQL,objConn,1,2
If user_name=”" OR user_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
Dim user_yr
user_yr=objRS(“yr”)
Dim user_dept
user_dept=objRS(“dept”)
Dim user_rollno
user_rollno=objRS(“rollno”)
Dim user_sess
user_sess=user_yr & “-” & objRS(“dept”) & “-” & user_rollno
Session(“User_Name”) = user_name
Session(“User_Type”) = 2
Session(“User_primary_key”)=user_sess
Response.Redirect “userframe.asp”
End If
objRS.Close
Set objRS=Nothing
objConn.Close
Set objConn=Nothing
%>
</center>
</body>
</html>