Forum Moderators: open

Message Too Old, No Replies

Help with Dreamweaver Log in User and adding URL parameter

         

anubis81

2:25 am on May 1, 2005 (gmt 0)

10+ Year Member



Ok, here's what I have so far. Using ASP VB with a MySQL database.

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

txbakers

4:38 am on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need a closing ASP delimiter and a closing quote after your redirect:

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

anubis81

2:29 pm on May 1, 2005 (gmt 0)

10+ Year Member



tx,

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_numRows

Set 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>&nbsp;</td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
<p>&nbsp; </p>
</form>
</td>
<td width="105" height="500" rowspan="5">&nbsp;</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
%>

txbakers

3:09 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You didn't do the second suggestion I gave you. The MM_redirect line is still showing delimiters.

anubis81

3:29 pm on May 1, 2005 (gmt 0)

10+ Year Member



tx,

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

txbakers

5:16 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dreamweaver takes a very simple process (validating a login & password against a Database) and gums it up with 40+ extra lines of code.

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.

anubis81

7:27 pm on May 1, 2005 (gmt 0)

10+ Year Member



Ok, so I think I have the problem cornered. Now all I need to do is finish it off. Redirect to the static page works great. Add in a static parameter and all is well. Add a recordset to the page, still OK. Just for kicks I add parameter I want merely as dynamic text and try to preview and it breaks down. Is the problem perhaps that the filter for the recordset is trying to get the filter variable from a form that is on the same page. I mean, there is no form variable available when the page loads. Is perhaps the solution to create a second page that actually processes the login information that could take the usr field from the previous page and apply it both to the login function as well as filtering the recordset?

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

anubis81

9:03 pm on May 1, 2005 (gmt 0)

10+ Year Member



So I might have jumped to conclusions....

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

mattglet

11:16 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As mentioned by txbakers:

You need to change the delimiter.

MM_redirectLoginSuccess="index.asp?Customer_ID=" & (rsredirect.Fields.Item("Customer_ID").Value)

Stuperfied

10:12 am on May 2, 2005 (gmt 0)

10+ Year Member



Great dreamweaver asp tutorials can be found on [webthang.co.uk,...] its where I learned ASP/VBScipt and it only took about 2 weeks to become very proficient at it using those tutorials.

anubis81

2:17 pm on May 2, 2005 (gmt 0)

10+ Year Member



Matt,

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

Stuperfied

5:39 am on May 3, 2005 (gmt 0)

10+ Year Member



Yeah, I didnt go through that cause I really hate manuals, lol. I just went through the tutorials and was amazed at how informative they are. I tried to just jump right into one of the advanced tutorials but got confused with all this jargon that I didnt understand. So I went back to the basic tutorials and trudged through. When I got through the basic tutorials, all the advanced ones were a breaze.

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.;)