Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 18th, 2003, 11:37 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Load one page according to the link

How do I use only one page but have different text or content load depending on which link was used to access the page. If I have a 3 useres accessing the page(member, guest, admin) can I custom the content without making 3 pages. I don't know where to start and I want to use as much asp as possible instead of taking the easy way out with html. There is going to be a login so I guess maybe I can use the variable from the login for the page, ie: (Guest,Member,Admin)

__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old November 18th, 2003, 12:32 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You most certainly could use the login value. Once you have that saved somewhere (the session?) then you could use that to determine the output on one page.

Here's a quick and dirty example:

<%Select Case Session("userType")
    Case 1%>
        This is the content for a guest
    <%Case 2%>
        This is the content for a member
    <%Case 3%>
        This is the content for an admin
<%End Select%>

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 18th, 2003, 12:41 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<%
dim objConn
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "Library"


'if Session("bValidUser") = True and Session("UserID") = "" then
'dim rsPersonIDCheck
'set rsPersonIDCheck = Server.CreateObject("ADODB.Recordset")
'dim strSQL
'strSQL = "SELECT User_ID FROM Users WHERE E_Mail = '" & Session("E_Mail") & "';"
'rsPersonIDCheck.Open strSQL, objConn
'if rsPersonIDCheck.EOF then
'Session("bValidUser") = False
'else
'Session("UserID") = rsPersonIDCheck("UserID")
'end if
'rsPersonIDCheck.Close
'end if
%>

If I use this to log in, is it the ("bVaildUser") that holds the value and is that what I would use in the select case?
I can't tell where it would return if it was a Member or an Admin.
 
Old November 18th, 2003, 02:40 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Let's do it this way instead!
A normal link
<a href="main.asp">Main Page</a>

How do I assign that link a variable to use in the select case and link in to another page. Would the include file hold the variable, in this case say it was called "main". Then on the main.asp page it would look like this?
<%Select Case Session("userType")
    Main%>
Content
<%End select%>

What goes in the userType field??

Thanks

 
Old November 18th, 2003, 03:31 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you plan on showing content based on the user type, then you'll need to store some user type with your user. you should add something like a "UserType" field to your user table. Then when you login the user by validating their username and password in from the table, you can retrieve the user type.

SELECT User_ID, UserType FROM ...

Then you can set that value to the session:

Session("UserType") = rsPersonIDCheck("UserType")

Then you can display the content with the select case I suggested (after changing the case test values to the right ones for you scenario).

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 03:42 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
... how to load a page without a trace ??? dk6607 ASP.NET 1.0 and 1.1 Professional 4 September 4th, 2007 09:10 AM
Bookmark this page link in Master page dschips ASP.NET 2.0 Basics 5 January 8th, 2007 11:05 AM
Page won't load data in IE rinventive PHP How-To 8 June 23rd, 2006 10:03 PM
LOGIN PAGE (does not link to the next page) [email protected] Classic ASP Databases 7 April 5th, 2006 01:28 PM
page load() task vijayapteET Classic ASP Basics 1 October 3rd, 2005 10:19 PM





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