11 Replies Latest reply on Oct 30, 2009 1:37 PM by mach6ix

    User Authentication

    mach6ix

      Got a site almost complete however the user authentication isn't working.

       

      Simply put, i wish my website to reference a PHP file, which is echoing a users authentication level. Via the Actionscript, Flash pushes the user to the frame on the timeline they have the authority to view.

       

      My PHP Code

       

      <?php
      echo 'checkLog=999';
      ?>

       

      My AS2 Code - This code is pasted in the first frame of the timeline

       

      appname="mikesapp"
      loadVariablesNum("newlogin.php", 0, "POST");

       

      //This verifys the users status and forwards them to the portion of the website they are authorized to access.//
      //Auth Level 100 = Regional Access, Auth Level 200 = Franchise Access, Auth Level 300 = Employee Access, Auth Level 400 = Denied Access and Back Button as they do not have the privliges to move forward from there.//

       


      this.onEnterFrame = function () {
          if(_root.checkLog == 100){
              _root.gotoAndStop("regional");
          }
          if(_root.checkLog == 200){
              _root.gotoAndStop("partner");
          }
          if(_root.checkLog == 300){
              _root.gotoAndStop("employee");
          }
          if(_root.checkLog == 999){
              _root.gotoAndStop("denied");
          }
      }

       

      Because the "checkLog" value is 999, the user should be forwarded to the "denied" label in the timeline however it is not as the site simply loops over and over.

       

      I'm sure Flash is accessing the "newlogin.php" file as when I rename it, flash errors stating it cannot locate the file. I have changed it back to the correct name since.

       

      Any help would be appreciated.

        • 1. Re: User Authentication
          Ned Murphy Adobe Community Professional & MVP

          Do you have a stop(); in the first frame?  Try putting: trace(_root.checkLog ); inside that enterframe function to see what it's seeing.

          1 person found this helpful
          • 2. Re: User Authentication
            mach6ix Level 1

            Thanks Ned.

             

            I added the stop(); and trace you had suggested.

             

            The output came out "undefined".

             

            ActionScript 2

             

            stop();
            appname="mikesapp"
            loadVariablesNum("newlogin.php", 0, "POST");

             

            //This verifys the users status and forwards them to the portion of the website they are authorized to access.//
            //Auth Level 100 = Regional Access, Auth Level 200 = Franchise Access, Auth Level 300 = Employee Access, Auth Level 400 = Denied Access and Back Button as they do not have the privliges to move forward from there.//

             

            {
            trace(_root.checkLog);
            }

             

            this.onEnterFrame = function ()

             

            {
                if(_root.checkLog == 100)
                {
                    _root.gotoAndStop("regional");
                }
                if(_root.checkLog == 200)
                {
                    _root.gotoAndStop("partner");
                }
                if(_root.checkLog == 300)
                {
                    _root.gotoAndStop("employee");
                }
                if(_root.checkLog == 999)
                {
                    _root.gotoAndStop("denied");
                }
            }

             

             

            Output

             

            undefined

             

            PHP

             

            <?php
            echo 'checkLog=999';
            ?>

             

            This should tell the site to push the user to the "denied" label (or any of them when the value is changed) however it is still is not working.

             

            Thanks for the suggestions Ned however any other help would be always appreciated.

             

            Cheers.

            • 3. Re: User Authentication
              Ned Murphy Adobe Community Professional & MVP

              I'm not sure how you coded the trrace, but I meant to put it inside the enterframe code, just before the conditionals.  That trace is telling you that the variable is undefined, meaning it doesn't exist.  Do you declare the checkLog variable in the _root timeline (var checkLog;)?  It's been awhile since I worked with loadomg data in AS2, but I think you need to declare the variable for it to be assigned a value from the loading.

              • 4. Re: User Authentication
                mach6ix Level 1

                Unfortunatly don't understand what you mean by a "conditional". As you may have figured out...i'm a newbie.

                 

                How or where are you suggesting the trace be placed?

                 

                Do you mean within the brackets within the function"()"

                trace(_root.checkLog );

                 

                stop();
                appname="mikesapp"
                loadVariablesNum("newlogin.php", 0, "POST");

                this.onEnterFrame = function ()


                //Do you mean to have it placed in the brakets of the above script "this.onEnterFrame = function(trace_root.checkLog);?//

                 

                {
                    if(_root.checkLog == 100)
                    {
                        _root.gotoAndStop("regional");
                    }
                    if(_root.checkLog == 200)
                    {
                        _root.gotoAndStop("partner");
                    }
                    if(_root.checkLog == 300)
                    {
                        _root.gotoAndStop("employee");
                    }
                    if(_root.checkLog == 999)
                    {
                        _root.gotoAndStop("denied");
                    }
                }

                 

                Thank you Mr. Murphy.

                • 5. Re: User Authentication
                  mach6ix Level 1

                  Hi researched trace(); and belive I have coded it correctly this time.

                   

                  The current PHP echo's value 999 so I would assume the output should paralell that however FALSE is what is displayed in the OUTPUT window.

                   

                  Again, your help is greatly appreciated.

                   

                  Actionscript

                   

                  stop();
                  appname="mikesapp"
                  loadVariablesNum("newlogin.php", 0, "POST");

                   

                  //This verifys the users status and forwards them to the portion of the website they are authorized to access.//
                  //Auth Level 100 = Regional Access, Auth Level 200 = Franchise Access, Auth Level 300 = Employee Access, Auth Level 400 = Denied Access and Back Button as they do not have the privliges to move forward from there.//
                  trace(_root.checkLog == 999);
                  this.onEnterFrame = function ()

                   

                  {
                      if(_root.checkLog == 100)
                      {
                          _root.gotoAndStop("regional");
                      }
                      if(_root.checkLog == 200)
                      {
                          _root.gotoAndStop("partner");
                      }
                      if(_root.checkLog == 300)
                      {
                          _root.gotoAndStop("employee");
                      }
                      if(_root.checkLog == 999)
                      {
                          _root.gotoAndStop("denied");
                      }
                  }

                   

                  PHP

                   

                  <?php
                  echo 'checkLog=999';
                  ?>

                  • 6. Re: User Authentication
                    Ned Murphy Adobe Community Professional & MVP

                    stop();
                    var appname="mikesapp";

                    var checkLog; // do you have this variable declared like this anywhere?
                    loadVariablesNum("newlogin.php", 0, "POST");

                    this.onEnterFrame = function ()

                    {

                        trace(_root.checkLog); // will repeatedly output the value until it passes a condition
                        if(_root.checkLog == 100) // if statements are conditionals
                        {
                            _root.gotoAndStop("regional");
                        }
                        if(_root.checkLog == 200)
                        {
                            _root.gotoAndStop("partner");
                        }
                        if(_root.checkLog == 300)
                        {
                            _root.gotoAndStop("employee");
                        }
                        if(_root.checkLog == 999)
                        {
                            _root.gotoAndStop("denied");
                        }
                    }

                    1 person found this helpful
                    • 7. Re: User Authentication
                      Ned Murphy Adobe Community Professional & MVP

                      I created a sample file using the code I showed, saved as a Flash 8 file. I added one more bit to remove the enterframe after the conditional is met to insure it doesn't run on forever.  It uses what you indicated as the PHP data file.  Here's a link to the file:

                       

                      http://www.nedwebs.com/Flash/AS2_LoadVariablesNum.fla

                      • 8. Re: User Authentication
                        mach6ix Level 1

                        Thanks Ned

                         

                        stop();
                        var appname="mikesapp";

                        var checkLog; // do you have this variable declared like this anywhere? - Like in other frames that contain Actionscript?

                         

                        loadVariablesNum("newlogin.php", 0, "POST");

                        this.onEnterFrame = function ()

                        {

                            trace(_root.checkLog); // will repeatedly output the value until it passes a condition - Which it is however listing as "undefined"
                            if(_root.checkLog == 100) // if statements are conditionals - Thank you for the "if" statement info and what a conditional is.
                            {
                                _root.gotoAndStop("regional");
                            }
                            if(_root.checkLog == 200)
                            {
                                _root.gotoAndStop("partner");
                            }
                            if(_root.checkLog == 300)
                            {
                                _root.gotoAndStop("employee");
                            }
                            if(_root.checkLog == 999)
                            {
                                _root.gotoAndStop("denied");
                            }
                        }

                         

                        Resulting Output - Which is looping even through there is a stop(); in frame 1 (included with the above AS)

                         

                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined
                        undefined

                         

                        • 9. Re: User Authentication
                          Ned Murphy Adobe Community Professional & MVP

                          Check my last posting

                          • 10. Re: User Authentication
                            mach6ix Level 1

                            Hi Ned,

                             

                            I really appreciate you taking the time to build that file for me.

                             

                            However, using the "newlogin.php" file in the same directory as the source you gave me, I find that it shows "undefined" (for the trace function i'm guessing) and it does not move beyond the first 10 frames (blank space).

                             

                            AS2 Script

                             

                            stop();
                            var appname="mikesapp";

                             

                            var checkLog; // do you have this variable declared like this anywhere?
                            loadVariablesNum("newlogin.php", 0, "POST");

                             

                            trace(_root.checkLog);

                             

                            this.onEnterFrame = function ()
                            {
                                if(_root.checkLog == 100) // if statements are conditionals
                                {
                                    _root.gotoAndStop("regional");
                                    delete this.onEnterFrame;
                                }
                                if(_root.checkLog == 200)
                                {
                                    _root.gotoAndStop("partner");
                                    delete this.onEnterFrame;
                                }
                                if(_root.checkLog == 300)
                                {
                                    _root.gotoAndStop("employee");
                                    delete this.onEnterFrame;
                                }
                                if(_root.checkLog == 999)
                                {
                                    _root.gotoAndStop("denied");
                                    delete this.onEnterFrame;
                                }
                            }

                             

                            PHP Script

                             

                            <?php
                            echo 'checkLog=999';
                            ?>

                             

                            Should move the flash file to the "denied" label of the timeline

                             

                            screenshot.png

                             

                            Cheers Ned as you've been a fantastic/responsive help thus far.

                             

                            Mike

                            • 11. Re: User Authentication
                              mach6ix Level 1

                              Hi Ned,

                               

                              I've got it all resolved and this has everything to do with your great help.

                               

                              Thank you.

                               

                              As embarassing as this is for me to admit, i was refering to the PHP and testing it without it being located in my HTDOCS folder of my xampp install. I've placed it in the root folder I created in there "members" and now when I reference http://localhost/members/newlogin.php the site behaves as it should.

                               

                              And I learned some new script as I saw how the "delete this.onEnterFrame;" stopped the return from returning forever.

                               

                              Again, a great help.

                               

                              Mike