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:

&lt;% If varCompany = "WhatEver" Then %&gt;
&lt;img src="ThisPicture.gif" width="30" height ="20"&gt;
&lt;% End If %&gt;

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

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 &lt;html&gt; tag you should see some code like:

&lt;%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
if (Session("MM_Username" &lt;&gt; "" then Recordset1__MMColParam = Session("MM_Username"
%&gt;
&lt;%
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
%&gt;

7. Add this line immediately after the recordset code:

&lt;% varCompany = (Recordset1.Fields.Item("company".Value) %&gt;

8. Locate the HTML for the image(s) that are to be shown or hidden according to the users company, something like:

&lt;td&gt;
&lt;img src="MyPicture.gif" width="30" height ="20"&gt;
&lt;/td&gt;

9. Modify it as follows:

&lt;td&gt;
&lt;% If varCompany = "WhatEver" Then %&gt;
&lt;img src="MyPicture.gif" width="30" height ="20"&gt;
&lt;% End If %&gt;
&lt;/td&gt;

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

Reply to this topic