4 Replies Latest reply on May 14, 2008 12:01 PM by collosal-G

    loadVariables and PHP

    collosal-G Level 1
      I am having a problem passing a list of variables into a PHP file using loadVariables. Flash makes contact with the PHP file, and the confirmation code is executed. The PHP file is sending back the email, but the variables are not being passed through. It has worked in the past, on this server, so I don't think that is the problem. I have searched this forum for an answer, but didn't see anything that relates, but I apologize if this is redundant.

      Also, is loadVariables outdated by loadVars?

      Here is my Flash code:
      function submitNotification (fieldNumber) {
      // Confirm Submission
      onData = function() {
      notify_mc.gotoAndStop ("sent");
      }

      // Set Variables
      name = notify_mc.input1_txt.text;
      email = notify_mc.input2_txt.text;
      learn = notify_mc.input3_txt.text;
      first = notify_mc.input4_txt.text;
      phone = notify_mc.input5_txt.text;

      // Test for Incomplete Fields
      for (i = 1; i <= fieldNumber; i++) {
      theTextField = "input" + i + "_txt";
      if (notify_mc[theTextField].text == "" || notify_mc[theTextField].text == "Required") {
      notify_mc[theTextField].text = "Required";
      notify_mc[theTextField].textColor = 0xFF0000;
      formComplete = false;
      break;
      } else {
      notify_mc[theTextField].textColor = 0x000000;
      formComplete = true;
      }
      }

      // Test For Incomplete Fields and Send Form
      if (formComplete) {
      loadVariables("testForm.php", "", "POST");
      // notify_mc.gotoAndStop ("sending");
      }
      }
        • 1. Re: loadVariables and PHP
          kglad Adobe Community Professional & MVP
          if your variables were defined within the same scope as your loadVariables statement, your variables would be transmitted.

          because your code appears to be "extracted" from its context, it's not possible to judge the scope of your variables and loadVariables statement.

          and yes, loadvars is the preferred as2 way of communicated between flash and php.
          • 2. Re: loadVariables and PHP
            collosal-G Level 1
            Thanks for the reply, kglad, but I am not sure what you mean by the code being out of context. There are input fields that accept data, and when the user hits the SUBMIT button, it calls the submitNotification function. What is not in context to determine the scope? I could provide more info if necessary.

            Thanks again,
            G
            • 3. Re: loadVariables and PHP
              kglad Adobe Community Professional & MVP
              it looks like you cut and pasted code snippets. so, for example, it's not possible to tell if some of those variables are defined inside functions and if they are, are they local to the function.
              • 4. Re: loadVariables and PHP
                collosal-G Level 1
                Hmm. The odd thing is that I have used this code a number of times, with the same PHP file, and it worked perfectly. I have tried to define the vars a number of ways, in the button handler, on the main timeline, etc. I even tried to hard code the variables with string data, with no luck. I am starting to wonder if there is an issue with the PHP file or its permissions.