Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Components
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Components Discussions specific to components in ASP 3.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Components section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 2nd, 2008, 02:26 PM
Registered User
Join Date: Apr 2008
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing session variables from login page.

I am trying to pass session variables from login page but I am getting an error. Can anyone help why?

My default page code is

'-- Simple function to replace single quotes --
Function ValidateStr(strValue)
    strTemp = strValue
    strTemp = Trim(strTemp)
    strTemp = Replace(strTemp,"'","''")
    ValidateStr = strTemp
End Function

'-- Check that form has been submitted --
If Request.Form("Submit") = "Login" Then
    '-- Grab form values --
    UserEmail = ValidateStr(Request.Form("UserEmail"))
    UserPassword = ValidateStr(Request.Form("UserPassword"))

    ' -- Check if both email and password were submitted -
    If UserEmail = "" OR UserPassword = "" Then
        strError = "You must enter both an email address and password."
    End If

    ' -- If no errors, continue --
    If strError = "" Then
        '-- Connect to DB and create recordset --
        Set conn = Server.CreateObject("ADODB.Connection")
        conn.Provider = "Microsoft.Jet.OLEDB.4.0"
        conn.Open Server.MapPath("login.mdb")
        Set rsLogin = Server.CreateObject("ADODB.recordset")

        '-- Select the data from the DB using the submitted information --
        strSQL = "SELECT UserID, UserEmail, UserPassword FROM tblUsers WHERE UserEmail = '" & UserEmail & "' AND UserPassword = '" & UserPassword & "'"
        rsLogin.Open strSQL, conn

        ' -- Check that user exists --
        If Not rsLogin.EOF Then
            '-- If match found, and user exists, then set session variable --
            Session("UserID") = rsLogin("UserID")
            ' -- Redirect to protected page --
            Response.Redirect "profile.asp"
            strError = "Login failed."
        End If
    End If
End If

<b><%= strError %></b><p />&nbsp;&nbsp;&nbsp;&nbsp;

<form name="login" method="post" action="default.asp">
  <table width="400" border="0" cellspacing="0" cellpadding="2">
      <td>Email Address</td>
      <td><input name="UserEmail" type="text" value="<%= UserEmail %>" /></td>
      <td><input name="UserPassword" type="password" value="<%= UserPassword %>" /></td>
      <td><input type="submit" name="Submit" value="Login" /></td>

My profile page code is

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Set conn = Server.CreateObject("ADODB.Connection")
        conn.Provider = "Microsoft.Jet.OLEDB.4.0"
        conn.Open Server.MapPath("login.mdb")

UserID = Session("UserID")
response.write "User ID: " & UserID
strSQL = "SELECT UserName FROM tblUsers WHERE UserID = " & UserID
Set loginRS = Conn.Execute(strSQL)

strUserName = loginRS("UserName")

response.write "Welcome " & strUserName & " to the password protected portion of my site."
<p>profile happy </p>
<p>&nbsp; </p>
The error I am getting is Microsoft Jet Database Engine (0x80040E14)
Syntax error (missing operator) in query expression 'UserID='./profile.asp, line 18

Please help.

  #2 (permalink)  
Old April 23rd, 2008, 11:54 PM
Authorized User
Join Date: Sep 2003
Location: Delhi, Delhi, India.
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra

Check if you have EnableSessionState On and rsLogin("UserID") is actually returning anything.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Variables with Login jflores1 Beginning PHP 2 January 10th, 2006 09:27 AM
Passing Session Variables to the Next Page jim.sullivan@telus.net ASP.NET 1.0 and 1.1 Professional 1 August 1st, 2004 06:25 PM
Passing Session Variables to the Next Page jim.sullivan@telus.net Classic ASP Databases 2 August 1st, 2004 01:59 PM
login page and session variables scdownload Classic ASP Basics 0 December 8th, 2003 06:13 PM

All times are GMT -4. The time now is 04:01 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.