Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session object

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
Below is my login page that works ok.
I have added another page which somebody wrote for me but they put a session in and I would like to know where to add the session in my login page or after my login page.
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<%

Dim Members__strUserID
Members__strUserID = &quot;xyz&quot;
if(Request.Form(&quot;UserID&quot;) <> &quot;&quot;) then Members__strUserID = Request.Form(&quot;UserID&quot;)

Dim Members__strPassword
Members__strPassword = &quot;123&quot;
if(Request.Form(&quot;Password&quot;) <> &quot;&quot;) then Members__strPassword = Request.Form(&quot;Password&quot;)

%> <%
set Membersragol = Server.CreateObject(&quot;ADODB.Recordset&quot;)
Members.ActiveConnection = &quot;dsn=Members;&quot;
Members.Source = &quot;SELECT * FROM Members WHERE UserID = '&quot; + Replace(Members__strUserID, &quot;'&quot;, &quot;''&quot;) + &quot;' AND Password = '&quot; + Replace(Members__strPassword, &quot;'&quot;, &quot;''&quot;) + &quot;'&quot;
Members.CursorType = 0
Members.CursorLocation = 2
Members.LockType = 3
Members.Open
Members_numRows = 0
%>
<%
If Members__strUserID <> &quot;xyz&quot; then
If Not Members.EOF Then
Session(&quot;svUserID&quot;) = (Members.Fields.Item(&quot;UserID&quot;).Value)
Session(&quot;svPassword&quot;) = (Members.Fields.Item(&quot;Password&quot;).Value)
Session(&quot;svAccessGroup&quot;) = (Members.Fields.Item(&quot;AccessGroup&quot;).Value)
strHomepage = Members.Fields.Item(&quot;HomePage&quot;).Value

Response.Redirect(strHomePage)
Else
Response.Redirect &quot;login.asp&quot;
End If
End If
%>
<----------here is the session that he put at the top of the pages--------->
<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session(&quot;blnIsUserGood&quot;) = False or IsNull(Session(&quot;blnIsUserGood&quot;)) = True then
'Redirect to unathorised user page
Response.Redirect&quot;denied.asp&quot;
End If
%>
 
assuming they only go to the homepage if their login is valid, I'd set the session variable here:

strHomepage = Members.Fields.Item(&quot;HomePage&quot;).Value
Session(&quot;blnIsUserGood&quot;) = True
Response.Redirect(strHomePage)
 
That works ok but the page that is supposed to display comes up blank would you by any chance look at it as someone else wrote it for me and its confusing for me.
 
if you view source on the page that's blank, what does it show?
 
It show this but there is a database connection and a bunch of asp.
I assume the connections is ok cause it woudl errror if not
<html>
<head>
<title>Authorised User</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<style>
body { font-family : Verdana; font-size : 8pt; }
td { font-family : Verdana; font-size : 8pt; }
a { font-family : Verdana; font-size : 8pt; text-decoration : none; }
</style>


</head>





<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#0000
 
This is all the code for the page got to go to lucnh i will check back later
<%
'If the session variable is False or does not exsist then redirect the user to the unauthorised user page
If Session(&quot;blnIsUserGood&quot;) = False or IsNull(Session(&quot;blnIsUserGood&quot;)) = True then
'Redirect to unathorised user page
Response.Redirect&quot;denied.asp&quot;
End If
%>
<html>
<head>
<title>Authorised User</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>

<style>
body { font-family : Verdana; font-size : 8pt; }
td { font-family : Verdana; font-size : 8pt; }
a { font-family : Verdana; font-size : 8pt; text-decoration : none; }
</style>


</head>


<%

Dim adoCon 'Database Connection Variable
Dim strCon 'Holds the Database driver and the path and name of the database
Dim rs 'Database Recordset Variable
Dim strSQL 'Database query sring
Dim strUserName 'Holds the user name


strUserName = request.querystring(&quot;name&quot;)
'Create a connection odject
Set adoCon = Server.CreateObject(&quot;ADODB.Connection&quot;)

'Database connection info and driver
strCon = &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=E:\writedatabase\Members.mdb&quot;

'Set an active connection to the Connection object
adoCon.Open strCon

'Create a recordset object
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)

'Initalise the strSQL variable with an SQL statement to query the database
strSQL = &quot;SELECT Members.* FROM Members WHERE Members.UserID ='&quot; & strUserName & &quot;'&quot;

'Query the database
rs.Open strSQL, strCon
%>


<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<%
WHILE NOT RS.EOF
%>
<FORM METHOD=POST ACTION=&quot;update.asp&quot;>
<INPUT TYPE=&quot;hidden&quot; value=&quot;<%=rs( &quot;id&quot; ) %>&quot; name=&quot;recordid&quot;>
<TABLE BORDER=&quot;0&quot; CELLSPACING=&quot;1&quot; CELLPADDING=&quot;0&quot;>


<tr>
<td><b>ID</TD><TD bgcolor=&quot;#cococo&quot;><%=RS( &quot;ID&quot; )%></TD>
</TR>
<TR>
<TD><B>Name</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;NAME&quot; ) %></TD>
</TR>
<TR>
<TD><B>UserID</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;USERID&quot; ) %></TD>
</TR>
<TR>
<TD><B>Password</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;PASSWORD&quot; ) %></TD>
</TR>
<TR>
<TD><B>Pic</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;Pic&quot; ) %></TD>
</TR>
<TR>
<TD><B>Level</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;LEVEL&quot; ) %></TD>
</TR>
<TR>
<TD><B>Hours</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;HOURS&quot; ) %></TD>
</TR>
<TR>
<TD><B>Ver</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;VER&quot; ) %></TD>
</TR>
<TR>
<TD><B>Mag</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;MAG&quot; ) %></TD>
</TR>
<TR>
<TD><B>Style</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;STYLE&quot; ) %></TD>
</TR>
<TR>
<TD><B>Chartype</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;Chartype&quot; ) %></TD>
</TR>
<TR>
<TD><B>Email</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;email&quot; ) %></TD>
</TR>
<TR>
<TD><B>Homepage</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;Homepage&quot; ) %></TD>
</TR>
<TR>
<TD><B>AccessGroup&nbsp;</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;AccessGroup&quot; ) %></TD>
</TR>
<TR>
<TD><B>IpAddr</TD>
<TD bgcolor=&quot;#cococo&quot;><%=rs( &quot;IpAddr&quot; ) %></TD>
</TR>

<TR>
<TD COLSPAN=&quot;2&quot; ALIGN=&quot;CENTER&quot;><A HREF=&quot;edit.asp?id=<%=rs( &quot;id&quot; ) %>&quot;>edit</A>
</TD>
</TR>

</TABLE>



</FORM>


<%
RS.MoveNext
WEND
%>

</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top