10 Replies Latest reply on Feb 20, 2007 8:38 PM by WestSide

    PLEASE!!! How do I have a Label dynamically refer to the current loggedin user's FirstName and LastName in my database?

    JohnLeger Level 1
      I have an HBox that becomes visible when a valid user logs in. The HBox contains a logout button and a label. How do I have the label dynamically refer to the current loggedin user's FirstName and LastName in my database? Below I included my HBox and ColdFusion component. ANY helpwould be appreciated!!!



      <<<<<<MY LoginHBox.mxml component starts HERE>>>>>>>
      <mx:HBox
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      width="100%"
      height="28"
      horizontalAlign="right"
      verticalAlign="middle"
      paddingRight="10">

      <mx:Script source="../actionScript/logout.as" />

      <!-- Connects Application to ColdFusion using Flash Remoting BEGINS -->
      <mx:RemoteObject
      id="cfService_LoginCFC"
      destination="ColdFusion"
      source="WebsiteApplication.cfc.LoginCFC"/>
      <!-- Connects Application to ColdFusion using Flash Remoting ENDS -->

      <mx:Label id="welcomeLabel"
      text="Welcome.."/> <<<<HOW do I have the text dynamically refer to the logged in users FirstName and LastName?

      <!-- logoutResultHandler() function points to the logout.as file -->
      <mx:Button id="logoutButton"
      label="Log Out"
      click="logoutResultHandler()"/>

      </mx:HBox>
      <<<<<<MY LoginHBox.mxml component ends HERE>>>>>>>



      <<<<<<MY LoginCFC.cfc component starts HERE>>>>>>>
      <cfcomponent>

      <!-- loginUser Function BEGINS -->
      <cffunction name="loginUser" access="remote" returntype="WebsiteApplication.cfc.UserCFC">
      <cfargument name="username" type="string" required="true">
      <cfargument name="password" type="string" required="true">

      <!--- The default user isn't logged in --->
      <cfset var user=createObject("component", "UserCFC")>

      <cfquery name="loginQuery" dataSource="TheChurchOnFire">
      SELECT Username, Password, AccessLevelID, FirstName, LastName
      FROM dbo.MembershipInfo
      WHERE
      Username = '#username#'
      AND Password = '#password#'
      </cfquery>
      <!--- The following cfif statement was absolutely critical in getting the
      authentication process fully working --->
      <cfif loginQuery.Username EQ "#username#" AND loginQuery.Password EQ "#password#">
      <cfset user.loggedin=true>
      <cfset user.username="#username#">
      <cfset user.roles="#loginQuery.AccessLevelID#">
      <cfreturn user>
      <cfelseif #username# EQ "username" AND #password# EQ "password">
      <cfset user.loggedin=true>
      <cfset user.username="#username#">
      <cfset user.roles="6">
      <cfreturn user>
      <cfelse>
      <cfreturn user>
      </cfif>

      </cffunction>
      <!-- loginUser Function ENDS -->

      </cfcomponent>
      <<<<<<MY LoginCFC.cfc component ends HERE>>>>>>>

      THANKS,

      John