3 Replies Latest reply on Apr 16, 2007 2:03 PM by kglad

    getURL() with PHP


      Okay, so I am building a registration form, but I want restrictions on who can access it. I have put together a login page (in flash) that passes the login info to a php script which then runs an SQL query and passes a response back whether or not the user should have access. I am using a LoadVars object called userRegistered. Now I've debugged every part of the problem and found where the cause is stemming from. When php is sending the info back to flash, through:

      echo 'authorized=ok';

      flash is recieving it as a property of userRegistered. IE.


      I have traced the properties and everything is returning fine. I then have an event handler for the onLoad:

      userRegistered.onLoad = myFunction;

      myFunction is set up as follows;

      function myFunction():Void {
      if (this.authorized == "ok") {
      } else {
      // create error message

      now, as I said, trace is showing me that the value of userRegistered.authorized is coming back as "ok". But I keep getting the error message I created, as if the "if" statement is equating to false. I have tried removing one of the "=" signs there by making the statement true and the getURL works then, however my script doesnt (give the error msg if log is wrong). Now, I would think this is just some sort of typo or something on my part, but I've been using similar if else statement for other properties of the another LoadVars and they all work fine. The weird thing is that my other LoadVars has a getURL attached in an "if else" statement (the same way) and it isn't working either. Thats why I'm wondering if this is some sort of bug or what. Someone please help! It's 2:30 PM and I've been trying to fix this since 6AM. I've chewed off all my fingernails and am pulling my hair out as we speak :S

      C Morrison

        • 1. Re: getURL() with PHP
          Greg Dove Level 4
          Have you tried in myFunction try using userRegistered.authorized instead of this.authorized - I would try that, although I can't say 100% it will fix it because I haven't checked.

          With the event handlers, I tend to always attach the function directly to the event Handler rather than assign it to a separately defined function. When I do that I know that 'this' should refer to the loadVars object.

          Also with sendAndLoad, I use a separate loadVars Object to receive the result. I don't know if this is necessary, I just got the habit from the original examples in the help files/livedocs... perhaps I should try using the same loadVars object in the future to save coding.
          • 2. Re: getURL() with PHP
            cmwpmm Level 1
            I've actually tried userRegistered.authorized rather than "this" and that's not working either. I am also actually using two different LoadVars (one for send and one for receive). The thing is that I am doing exactly the same action with several variables being sent back from PHP. All the if... else statements work except for the ones that include a "getURL()" in them. That's why I'm wondering if its a bug. For some reason the "getURL()" seems to be altering the validation of the if(). I hope that made sense. I've never heard of an if... else valuating as false due to the actions within the {}. But, thank you for your suggestions:)
            • 3. Re: getURL() with PHP
              kglad Adobe Community Professional & MVP
              check for white space (eg, userRegistered.authorized.length)
              and remove it, if found