Forum Moderators: open
A login page with the usual form. When login is successful the user is redirected to an index.asp page within the "clients" directory. This index.asp page contains a recordset that holds a list of jobs and their dates in a repeating table. What I would like to do is pass from the login page to the index page some form of either URL parameter or form variable that changes depending on who logs in. i.e. bob logs in and is redirected to .../index.asp?Customer_ID=1 and jim logs in and is redirected to .../index.asp?Customer_ID=2, etc.
I've created a recordset in the login page that contains the username (usr field) and the customer ID (Customer_ID) field. I set the filter to use the form variable from the login form username text field. When applying the User Authentication behavior and selecting the page to be redirected to I browse to the index.asp page I have the option to add parameters. I select the "Customer_ID" entry from the recordset and allow Dreamweaver to do it's thing. When attempting to preview the page in browser though I get the following error.
Technical Information (for support personnel)
* Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/ghost_light/testgallery/login.asp, line 31, column 71
MM_redirectLoginSuccess="index.asp?Customer_ID=<%=(rsuser.Fields.Item("Customer_ID").Value)
----------------------------------------------------------------------^
* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
* Page:
GET /ghost_light/testgallery/login.asp
Any thoughts?
Thanks in advance,
David
MM_redirectLoginSuccess="index.asp?Customer_ID=<%=(rsuser.Fields.Item("Customer_ID").Value) %>"
or, most likely, you don't need the delimiters since you are already in some tags during their login procedure, in which case the line would look like:
MM_redirectLoginSuccess="index.asp?Customer_ID=" & rsuser.Fields.Item("Customer_ID").Value
Thanks for the reply. Neither line of code seems to alleviate the problem though. The first line is what I already had in place and the second one gives an even longer error message. Below is the code for the page if it helps.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="../Connections/ghostlight.asp" -->
<%
Dim rsuser__MMColParam
rsuser__MMColParam = "1"
If (Request.Form("Usr") <> "") Then
rsuser__MMColParam = Request.Form("Usr")
End If
%>
<%
Dim rsuser
Dim rsuser_numRowsSet rsuser = Server.CreateObject("ADODB.Recordset")
rsuser.ActiveConnection = MM_ghostlight_STRING
rsuser.Source = "SELECT Customer_ID, Usr FROM ghostlight.customers WHERE Usr = '" + Replace(rsuser__MMColParam, "'", "''") + "'"
rsuser.CursorType = 0
rsuser.CursorLocation = 2
rsuser.LockType = 1
rsuser.Open()
rsuser_numRows = 0
%>
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername=CStr(Request.Form("usr"))
If MM_valUsername <> "" Then
MM_fldUserAuthorization=""
MM_redirectLoginSuccess="index.asp?Customer_ID=<%=(rsuser.Fields.Item("Customer_ID").Value)%>"
"MM_redirectLoginFailed="login.asp"MM_flag="ADODB.Recordset"set MM_rsUser = Server.CreateObject(MM_flag) MM_rsUser.ActiveConnection = MM_ghostlight_STRING MM_rsUser.Source ="SELECT Usr, Pwd"If MM_fldUserAuthorization<>""Then MM_rsUser.Source = MM_rsUser.Source&","&MM_fldUserAuthorization MM_rsUser.Source = MM_rsUser.Source&"FROM ghostlight.customers WHERE Usr='"&Replace(MM_valUsername,"'","''")&"' AND Pwd='"&Replace(Request.Form("pwd"),"'","''")&"'"MM_rsUser.CursorType = 0 MM_rsUser.CursorLocation = 2 MM_rsUser.LockType = 3 MM_rsUser.Open If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then ' username and password match - this is a valid user Session("MM_Username") = MM_valUsername If (MM_fldUserAuthorization<>"") Then Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value) Else Session("MM_UserAuthorization") =""End If if CStr(Request.QueryString("accessdenied"))<>""And false Then MM_redirectLoginSuccess = Request.QueryString("accessdenied") End If MM_rsUser.Close Response.Redirect(MM_redirectLoginSuccess) End If MM_rsUser.Close Response.Redirect(MM_redirectLoginFailed) End If %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ghost Light Photography - Login</title>
<link href="../global.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../rollover.js" type="text/JavaScript"></script>
</head>
<body onload="MM_preloadImages('../imgs/Port_button_ov.jpg','../imgs/Stock_button_ov.jpg','../imgs/login_button_ov.jpg','../imgs/contact_button_ov.jpg')">
<table width="726" border="0" align="center">
<tr>
<td><img src="../imgs/ghostbanner.jpg" width="726" height="85"></td>
</tr>
</table>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="145" height="100"><a href="../port" target="_top" onClick="MM_nbGroup('down','group1','port','',1)" onMouseOver="MM_nbGroup('over','port','../imgs/Port_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/Port_button.jpg" alt="" name="port" width="145" height="31" border="0" onload=""></a></td>
<td width="475" height="500" rowspan="5"><form ACTION="<%=MM_LoginAction%>" method="POST" name="login" id="login">
<table width="251" border="0" align="center">
<tr>
<td width="86">Username</td>
<td width="155"><input name="usr" type="text" id="usr" /></td>
</tr>
<tr>
<td>Password</td>
<td><input name="pwd" type="text" id="pwd" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<p> </p>
</form>
</td>
<td width="105" height="500" rowspan="5"> </td>
</tr>
<tr>
<td height="100"><a href="../headshots" target="_top" onClick="MM_nbGroup('down','group1','head','',1)" onMouseOver="MM_nbGroup('over','head','../imgs/Headshts_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/Headshts_button.jpg" alt="" name="head" width="145" height="31" border="0" onload=""></a></td>
</tr>
<tr>
<td height="100"><a href="../stock" target="_top" onClick="MM_nbGroup('down','group1','stock','',1)" onMouseOver="MM_nbGroup('over','stock','../imgs/Stock_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/Stock_button.jpg" alt="" name="stock" width="145" height="31" border="0" onload=""></a></td>
</tr>
<tr>
<td height="100"><a href="../login.asp" target="_top" onClick="MM_nbGroup('down','group1','login','',1)" onMouseOver="MM_nbGroup('over','login','../imgs/login_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/login_button.jpg" alt="" name="login" width="145" height="31" border="0" onload=""></a></td>
</tr>
<tr>
<td height="100"><a href="../contact.html" target="_top" onClick="MM_nbGroup('down','group1','contact','',1)" onMouseOver="MM_nbGroup('over','contact','../imgs/contact_button_ov.jpg','',1)" onMouseOut="MM_nbGroup('out')"><img src="../imgs/contact_button.jpg" alt="" name="contact" width="145" height="31" border="0" onload=""></a></td>
</tr>
</table>
</body>
</html>
<%
rsuser.Close()
Set rsuser = Nothing
%>
I did copy and paste the second directly. As noted in my reply the second line gave an even longer error message which I'll post below. Thanks for your patience.
Technical Information (for support personnel)
* Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/ghost_light/testgallery/login.asp, line 32
"MM_redirectLoginFailed="login.asp"MM_flag="ADODB.Recordset"set MM_rsUser = Server.CreateObject(MM_flag) MM_rsUser.ActiveConnection = MM_ghostlight_STRING MM_rsUser.Source ="SELECT Usr, Pwd"If MM_fldUserAuthorization<>""Then MM_rsUser.Source = MM_rsUser.Source&","&MM_fldUserAuthorization MM_rsUser.Source = MM_rsUser.Source&"FROM ghostlight.customers WHERE Usr='"&Replace(MM_valUsername,"'","''")&"' AND Pwd='"&Replace(Request.Form("pwd"),"'","''")&"'"MM_rsUser.CursorType = 0 MM_rsUser.CursorLocation = 2 MM_rsUser.LockType = 3 MM_rsUser.Open If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then ' username and password match - this is a valid user Session("MM_Username") = MM_valUsername If (MM_fldUserAuthorization<>"") Then Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value) Else Session("MM_UserAuthorization") =""End If if CStr(Request.QueryString("accessdenied"))<>""And false Then MM_redirectLoginSuccess = Request.QueryString("accessdenied") End If MM_rsUser.Close Response.Redirect(MM_redirectLoginSuccess) End If MM_rsUser.Close Response.Redirect(MM_redirectLoginFailed) End If
* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
* Page:
GET /ghost_light/testgallery/login.asp
Their update/delete routines are even worse.
You can clean out most of that junk and write it in a few lines, which will work.
It's hard to tell from the post here, but since your are using VB as the default language, VB needs to ahve each command on a separate line. It looks like the code is bunched together in the error message, but that could just be the posting here.
The first step to debugging something like that would be to remove your parameter in the redirect and just redirect to a static page.
then, hardcode a parameter, then finally make it a true dynamic parameter.
You're just running into a syntax error somewhere and need to back out of it and see what it needs.
I tried this by copying the asp code from login.asp to the head area of login2.asp. I created a recordset in login2.asp that contains the usr record and the Customer_ID record and told it to filter by usr from form variable usr. I then inserted the dynamic variable into the redirect line.
Now the original login.asp loads up just fine (of course) and typing in my username and password (test1 and test2 respectively) redirects me properly to the index.asp page with one exception. The dynamic URL parameter is missing (index.asp?Customer_ID= ).
The redirect line of code in login2.asp is
MM_redirectLoginSuccess="index.asp?Customer_ID=<%=(rsredirect.Fields.Item("Customer_ID").Value)%>"
What am I missing here? Am I completely barking up the wrong tree with this two pages idea?
Thanks again,
David
I did some more troubleshooting and realized that although I changed the action for the form in the properties inspector it didn't actually change the code for some reason. Now that I've redirected the form to POST to login2.asp I am greeted with same error message from before. It must be a syntax thing but I just don't know enough ASP to know where.
Technical Information (for support personnel)
* Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/ghost_light/testgallery/login2.asp, line 33, column 75
MM_redirectLoginSuccess="index.asp?Customer_ID=<%=(rsredirect.Fields.Item("Customer_ID").Value)
--------------------------------------------------------------------------^
* Browser Type:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
* Page:
POST 33 bytes to /ghost_light/testgallery/login2.asp
* POST Data:
usr=test1&pwd=test2&Submit=Submit
Thanks for the retip on the delimiter. Seems to have needed a combonation of the two separate pages and the new syntax. Thanks for helping a new guy get on his feet.
Stuperfied,
Thanks for the tip on the tutorials. Since my site is turning out to be more dynamic than originally planned I'll be sure to check out the page. "The Missing Manual" is great for Dreamweaver but isn't specialized enough on the dynamic areas and scripting languages and such.
David
I recommend the Dreamweaver MX Files Tutorials at [webthang.co.uk...] that's tutorial number 1 of 5. It guides you through everything you need to know in order to setup a dynamic ASP/MySQL site using Dreamweaver. Its the main one I used to learn ASP/VBScript.;)