Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login and Directed to certain page????????

Status
Not open for further replies.

lovecf

Programmer
Mar 4, 2001
9
0
0
US
I am looking for examples of logining in someone,:
Userid:__________, Password:___________, and then based on there permissions (another field in the database) sending them to a certain form for viewing information on candidates,.......... If you have a permission of Me, then you see a form which lists all the fields, if NOT, then you see the basic information and thats all. I am looking for coding examples on how to accomplish this, please be specific.

Thank You

Michael
 
You can use this as the login page.
Retrieves username,password and a list of pagenumbers(ACL) that the user has access to view.
------------------

<CFIF IsDefined(&quot;URL.Verify&quot;) AND URL.Verify IS
NOT &quot;&quot;>
<CFIF IsDefined(&quot;FORM.Username&quot;) AND FORM.Username IS NOT &quot;&quot;>
<CFIF IsDefined(&quot;FORM.Password&quot;) AND FORM.Password IS NOT &quot;&quot;>

<CFQUERY NAME=&quot;Auth_Query&quot; datasource=&quot;#Application.DSN#&quot; dbtype=&quot;ODBC&quot;>
SELECT * FROM dbo.Authentication
WHERE Username = '#FORM.Username#'
AND Password = '#FORM.Password#'
</CFQUERY>
<CFIF #Auth_Query.RecordCount# IS 0>
<script language=&quot;javascript&quot;>
alert (&quot;Invalid username/password combination.
Please try again.&quot;);
self.location=&quot;login_index.cfm&quot;;
</script>
<CFABORT>
<CFELSE>
<CFLOCK scope=&quot;Session&quot; timeout=&quot;3&quot; type=&quot;Exclusive&quot;>
<CFOUTPUT>
<CFSET SESSION.USERNAME = Auth_Query.Username>
<CFSET SESSION.PASSWORD = Auth_Query.Password>
<CFSET SESSION.ACL = Auth_Query.ACL>
</CFOUTPUT>
</CFLOCK>
<CFLOCATION URL=&quot;login_MainMenu.cfm&quot;>
</CFIF>
</CFIF>
</CFIF>
<CFELSE>
<html><head><title>Administration Area - Coastal Federal Intranet</title>
<LINK REL=&quot;STYLESHEET&quot; TYPE=&quot;text/css&quot; HREF=&quot;../styles/cfed_style.css&quot;>
</head><body>
<TABLE align=&quot;center&quot; width=&quot;400&quot;><TR><TD align=&quot;center&quot; bgcolor=&quot;green&quot;>
<TABLE align=&quot;center&quot; width=&quot;400&quot; bgcolor=&quot;#ffffff&quot;><TR><TD align=&quot;center&quot;>
<IMG SRC=&quot;../images/logo.gif&quot; WIDTH=&quot;156&quot; HEIGHT=&quot;106&quot; ALT=&quot;Intranet Administration Area&quot; BORDER=&quot;0&quot;>
</TD><TD><CFFORM action=&quot;login_index1.cfm?Verify=User&quot; method=&quot;post&quot;><br>
<TABLE>
<TR><TD class=&quot;dropbox&quot;><b>Username</b></TD><TD><CFINPUT name=&quot;Username&quot; size=&quot;15&quot; maxlength=&quot;15&quot; REQUIRED=&quot;yes&quot; Message=&quot;Username field is blank!&quot;></TD></TR>
<TR><TD class=&quot;dropbox&quot;><b>Password</b></TD><TD><CFINPUT name=&quot;Password&quot; type=&quot;password&quot; size=&quot;15&quot; maxlength=&quot;15&quot; REQUIRED=&quot;yes&quot;Message=&quot;Password field is blank!&quot;></TD></TR>
<TR><TD colspan=&quot;2&quot;><INPUT type=&quot;submit&quot; value=&quot;Login&quot; class=&quot;sbutton&quot; ALT=&quot;Login&quot; TITLE=&quot;Login&quot;></CFFORM></TD></TR>
</TABLE>
</TD></TR></TABLE>
</TD</TR></TABLE>
</body></html>
</CFIF>

--------------------------
Use this to check if their access level allows them
to view the specific page.
--------------------------

<!---- Page Access Number
<CFSET PageAccessNum = 1>

<CFIF NOT ListContains(SESSION.ACL, 99)>
<CFIF NOT (IsDefined(&quot;SESSION.USERNAME&quot;))
OR NOT (IsDefined(&quot;SESSION.PASSWORD&quot;))
OR NOT ListContains(SESSION.ACL,PageAccessNum)>
<script language=&quot;JavaScript&quot;>
alert (&quot;Invalid username/password combination.
Please try again.&quot;);
self.location=&quot;../login_index.cfm&quot;;
</script>
<CFABORT>
</CFIF>
<CFELSE>
<!-----Page Contents----->
</CFIF>

Thanks,
Dave

 
Checkout
This is a way to make your site modular. Index.cfm uses switch/ case logic based on URL parameters passed to it.

index.cfm?x=client&z=login
index.cfm?x=client&z=shop&CID=1234

Index.cfm includes a Display.cfm at the bottom, which sets the overall look of the site has its own set of includes in the content area. The included templates are #template1#, #template2# etc.. these template variables are set by index.cfm based on what case resolves as true.

One of these cases might set template1=login.cfm .. which will then be included in Display.cfm and shown to the user. Here you can ask for user/pass, and submit to form action=&quot;index.cfm?x=client&z=verifyLogin&quot; . This case runs the query to check the user/pass, and if succeeds sets a cookie, and template1=home.cfm. Display.cfm includes home.cfm and is shown to the user.

Every time index.cfm is run, the clients system is checked for the existence of a cookie.. if it exists, the user will never see the login page.
 
OK skppyny, which part is the login form and which part is the action form? Somewhat confused, but then again, with this project that I am working on it is getting crazier every moment because one person wants one form and the other person wants things there way.


thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top