Trouble getting CF user privileges to work correctly?
Hi I have been going around in circles all afternoon trying to get user �privileges� to work correctly.  I am assuming it is something with session variables that I am implementing incorrectly. I am including what I have done (before I really muddled things up) and would be grateful if any of you could offer any ideas, examples etc.

The Access database contains �privilege� column which is either Admin or User. The only difference is if you are a user you shouldn�t be able to check enrollment for a class from the home page.

Thanks a bunch!

<HTML>
<!- reference to style sheet -!>
<LINK REL=stylesheet TYPE="text/css" HREF=""> <!---If the login form was filled out, run this code
     If the from hasn't been filled out yet, jump to the
     next CFELSE and display the form.--->
<cfparam name='message' default=''>
<CFIF isdefined('Form.EID')>

<!---This query looks for the EID and ePassword that was
       entered in the login form.  If it does not find a match
       the 'RecordCount' will be 0 and you will know that the user
       should not be given access.--->
<CFQUERY datasource= "CFCGtraining0" name='Check'>
    SELECT * FROM employee_table
    WHERE EID = '#Form.EID#' AND ePassword = '#Form.ePassword#'
   </CFQUERY>

   <cfif '#Check.RecordCount#' IS 0>
     <!--- we have an invalid request because there were
                no matching EID/ePassword in the DataBase--->
     Sorry, the EID or Password entered was invalid<BR>
     <a href="" to EID Home</a>
<CFElse>
      <!--- we have at least one match so we give them two
          variables.  Auth and Admin that we can use later
          to determine whether they are allowed to view pages
          or not.  A secure page needs to verify that Auth is
          'Yes' and can then use Admin to display the EID--->

      <!---Set there 'Authorization level' to 'Yes'--->
      <CFSET Session.Auth ='Yes'>

      <!---Store their EID in the Admin variable if you
           want to display their name to them on a page later--->
      <CFSET Session.Admin =Form.EID>

      <!---The user is now logged in.  Send them to your application--->
      <CFLOCATION url=''>

      </CFIF>

<!---Display the login form --->
<CFELSE>
<CENTER> <H1>Welcome to the Login Page</H1>
<H2>Please Log in Below:</H2>

<TABLE>

<cfoutput>
     <TR>
<TD><CFFORM Name= Login action='' method='post'>
      EID:&nbsp;<INPUT type='text' name='EID'Required="yes" message="Please enter your EID"><BR>
      Password:&nbsp;<INPUT type='Password' name='ePassword' Required="yes" message="Please enter your password"><BR>
      <INPUT Name= "Submit" type= "Submit" value= "Continue">
      <INPUT type= 'Reset' value= "Reset"> <br>
      <a href="" here for a new login ID</a>
    </CFFORM></TD>
</TR>
</cfoutput>
</CFIF>
</HTML>

<HTML>
<!- reference to style sheet -!>
<LINK REL=stylesheet TYPE="text/css" HREF=""> <HEAD>
<TITLE>EID Home</TITLE>
</HEAD>

<CENTER> <H1>Welcome to the EID Home Page!</H1>
<H2> Please select an one of the following options: </H2>

<CFOutput>
<CFForm Name = Home Action = '' METHOD="POST">
<TABLE width="30%">
<TR>
<TD align= "Right">Check schedule</TD>
<TD align= "left"><CFINPUT TYPE="RADIO" NAME="index" VALUE="1"></TD>
<TD></TD>
</TR>
<TR>
<TD  align= "Right">Register for a class</TD>
<TD align= "left"><CFINPUT TYPE="RADIO" NAME="index" VALUE="2"></TD>
<TD></TD>
</TR>
<TR>
<TD  align= "Right">Drop a class</TD>
<TD align= "left"><CFINPUT TYPE="RADIO" NAME="index" VALUE="3"></TD>
<TD></TD>
</TR>
<TR>
<TD  align= "Right">Check enrollment for a class</TD>
<TD align= "left"><CFINPUT TYPE="RADIO" NAME="index" VALUE="4"></TD>
</TD>
<TD></TD>
</TR>

</TABLE>
<INPUT TYPE="SUBMIT" VAlUE="Continue">
</CENTER>
</CFForm>
</CFOUTPUT>
</HTML>



[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to