Forums
This topic is locked
redirect user and filter information
Posted 26 Jan 2002 20:52:14
1
has voted
26 Jan 2002 20:52:14 Anton Sutterlueti posted:
Hi all i got to the point where i need some serious help, here is the proplem i have:I crreated a loginpage where the user can login, the user has the following tables,
username, password, email, fname, lname, company,
then i have a table for pictures, that include: picname, filename, company,
now what i want to do is the following when a users logs in, he will only see the pictures that he supposed to see, that will be driven by the company field,
does anyone has a tutorial on that or can help me, i dont know what to do <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
also is it possible that i can assign a picture to more then one users company, that would be cool
please write me back as fast as possible,
all help is appriciated
best regards
Anton Sutterlueti
Replies
Replied 27 Jan 2002 10:49:30
27 Jan 2002 10:49:30 Owen Eastwick replied:
If you are using UD's login behavior:
First create a recodset to find the company for that user:
varUser = Replace(Sesssion("MM_Username", "'", "''"
RecordsetName.Source = "SELECT Company FROM UserTable WHERE Username LIKE '" & varUser & "'"
Then create a variable to hold the company name for this particular user:
varCompany = (RecordsetName.Fields.Item("Company".Value)
Then around the images:
<% If varCompany = "WhatEver" Then %>
<img src="ThisPicture.gif" width="30" height ="20">
<% End If %>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
First create a recodset to find the company for that user:
varUser = Replace(Sesssion("MM_Username", "'", "''"
RecordsetName.Source = "SELECT Company FROM UserTable WHERE Username LIKE '" & varUser & "'"
Then create a variable to hold the company name for this particular user:
varCompany = (RecordsetName.Fields.Item("Company".Value)
Then around the images:
<% If varCompany = "WhatEver" Then %>
<img src="ThisPicture.gif" width="30" height ="20">
<% End If %>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 29 Jan 2002 02:35:02
29 Jan 2002 02:35:02 Anton Sutterlueti replied:
could you tell it me please more in detail, i dont get it. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> like where do i have to creat this varible and can i filter more then one pic....
thx for the help:
best regards
Anton Sutterlueti
thx for the help:
best regards
Anton Sutterlueti
Replied 29 Jan 2002 04:30:38
29 Jan 2002 04:30:38 Owen Eastwick replied:
Use Recordset (Query) in the data bindings window.
1. Click on the Selected radio button and choose the company field from your table.
2. In the filter list select the username field.
3. Select Session variable from the list.
4. Type MM_Username in the text box next to it.
5. Click OK.
6. Switch the page to code view, above the <html> tag you should see some code like:
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Session("MM_Username" <> "" then Recordset1__MMColParam = Session("MM_Username"
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_ZebideeTestCon_STRING
Recordset1.Source = "SELECT Company FROM UserTableName WHERE username = '" + Replace(Recordset1__MMColParam, "'", "''" + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
7. Add this line immediately after the recordset code:
<% varCompany = (Recordset1.Fields.Item("company".Value) %>
8. Locate the HTML for the image(s) that are to be shown or hidden according to the users company, something like:
<td>
<img src="MyPicture.gif" width="30" height ="20">
</td>
9. Modify it as follows:
<td>
<% If varCompany = "WhatEver" Then %>
<img src="MyPicture.gif" width="30" height ="20">
<% End If %>
</td>
By the way if you might need to rename the fields username and password in your database table, I think these are reserved words, but I'm not certain, if it works don't worry about it.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
1. Click on the Selected radio button and choose the company field from your table.
2. In the filter list select the username field.
3. Select Session variable from the list.
4. Type MM_Username in the text box next to it.
5. Click OK.
6. Switch the page to code view, above the <html> tag you should see some code like:
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Session("MM_Username" <> "" then Recordset1__MMColParam = Session("MM_Username"
%>
<%
set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_ZebideeTestCon_STRING
Recordset1.Source = "SELECT Company FROM UserTableName WHERE username = '" + Replace(Recordset1__MMColParam, "'", "''" + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 3
Recordset1.Open()
Recordset1_numRows = 0
%>
7. Add this line immediately after the recordset code:
<% varCompany = (Recordset1.Fields.Item("company".Value) %>
8. Locate the HTML for the image(s) that are to be shown or hidden according to the users company, something like:
<td>
<img src="MyPicture.gif" width="30" height ="20">
</td>
9. Modify it as follows:
<td>
<% If varCompany = "WhatEver" Then %>
<img src="MyPicture.gif" width="30" height ="20">
<% End If %>
</td>
By the way if you might need to rename the fields username and password in your database table, I think these are reserved words, but I'm not certain, if it works don't worry about it.
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo