Forums

ASP

This topic is locked

Displaying on a users info

Posted 05 Dec 2002 19:35:05
1
has voted
05 Dec 2002 19:35:05 Tom Chase posted:
GOD! I FEEL LIKE A TOTAL NEWBEE AS OF LATE...

I have a page which allows a user to login (www.impact-printing.com/login.asp), which appears to work fine... where my problem is I cannot get the destination page (www.impact-printing.com/client/client_home.asp) to display the correct recordset in regards to the username enter....

I have two accounts setup on this test:
U: Tom P: squeek and U: Bill P:123456

When I log in under either account it only displays info from I believe the first recordset. Can someone help me out and explain in as simple terms as possible.

Thanks

Tom

Replies

Replied 05 Dec 2002 22:20:53
05 Dec 2002 22:20:53 Dave Blohm replied:
how are you passing the values from page 1 to page 2...can you copy and paste the code from both pages in here so I can see how you're doing things?

Doc
Rangewalk Digital Studios
Replied 06 Dec 2002 10:48:58
06 Dec 2002 10:48:58 Tom Chase replied:
Actually, thats my problem... I have read through the info that came with dreamweaver MX - and all I have come to the conculsion is that the login behavior creates a session called "MM_username" - thats where I am at I haven't added anything else.. mainly becuase I have no clue how to...

Tom

Replied 06 Dec 2002 15:19:27
06 Dec 2002 15:19:27 Dave Blohm replied:
OK, I write my own login routines...While DWMX makes it easier, it comes at a price...lots of extra code...

I used the following login code (i changed file names) for a client of mine...its a one page form/action page that "does" the login...it also returns specific error messages if the user name (called email in this example) does not exist in the DB or the password is in accureate (I stripped out my Register New User and Retrieve Password code...) then stores 2 session variables--one that says "I'm logged in." and the other that says "This is my user ID." On the second page, you can build your recordset based on the user ID session variable we set.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
' ::::: SET UP FOR ERRORS

varError = Request.QueryString("err"
select case varError
case "pw"
varError = "The password you entered does not match the one on file."
case "uid"
varError = "The email address you entered is not in the database."
End Select

' ::::: DETERMINE IF THIS IS INITIAL PAGE LOAD OR FORM ACTION

If Request.Form("email" <> "" Then

Set rsLogin = Server.CreateObject("ADODB.Recordset"
rsLogin.ActiveConnection = "driver={mysql};database=YOUR_DB;server=YOUR_SERVER;uid=USER;pwd=PW"
rsLogin.Source = "SELECT * FROM Guests WHERE email ='" & Request.Form("email" & "'"
rsLogin.CursorType = 0
rsLogin.CursorLocation = 2
rsLogin.LockType = 1
rsLogin.Open()

' ::::: DETERMINE IF THE USER NAME EXISTS IN THE DB
If Not rsLogin.BOF And Not rsLogin.EOF Then
' ::::: DETERMINE IF THE PASSWORD IS CORRECT
If rsLogin.Fields.Item("password".Value = Request.Form("password" Then
' ::::: IF THE PW IS CORRECT, SET SESSION VARIABLES FOR LOGGED IN AND USER ID
Session("LoggedIn" = True
Session("UserNumber" = rsLogin.Fields.Item("id".Value
Response.Redirect "page2.asp"
Else
Response.Redirect "login_sm.asp?err=pw"
End If
Else
Response.Redirect "login_sm.asp?err=uid"
End If
End If
%>
<html>
<head>
<title>Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div id="Layer1" style="position:absolute; left:183px; top:76px; width:516px; height:183px; z-index:1; visibility: visible;">
<form name="form1" method="POST" action="login_sm.asp">
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td colspan="2"><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>LOGIN</strong></font></td>
</tr>
<tr>
<td width="34%"><strong><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Email
Address</font></strong></td>
<td width="66%"> <input type="text" name="email"></td>
</tr>
<tr>
<td><strong><font color="#003366" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password</font></strong></td>
<td width="66%"> <input type="password" name="password"></td>
</tr>
<tr align="center">
<td colspan="2"><strong><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif"><%= varError %></font></strong></td>
</tr>
<tr>
<td colspan="2" align="center"> <input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>

<tr>
<td colspan="2" align="center"><strong></strong></td>
</tr>
</table>
<br>
<br>
</form>
</div>
<table width="752" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="752"></td>
</tr>
</table>
<br>
</body>
</html>



Let me know if you have any other questions.

Hope this helps...

Doc
Rangewalk Digital Studios

Reply to this topic