2 Replies Latest reply on Jan 27, 2010 7:14 AM by Rootman224

    Error #2007

    Rootman224 Level 1

      These are the code for the php and flash page:

      // Create local variables from the Flash ActionScript posted variables
      $senderName   = $_POST['userName'];
      $senderEmail     = $_POST['userEmail'];
      $senderMessage = $_POST['userMsg'];


      // Strip slashes on the Local variables for security
      $senderName   = stripslashes($senderName);
      $senderEmail     = stripslashes($senderEmail);
      $senderMessage   = stripslashes($senderMessage);


      // IMPORTANT - Change these lines to be appropriate for your needs - IMPORTANT
      $to = "erni_annor@yahoo.com";            
      $from = "$senderEmail";
      $subject = "Contact from gharweg.org.uk";
      // Modify the Body of the message however you like
      $message = "Message from Gharweg.org.uk:


      Their Name:   $senderName


      Their Email:   $senderEmail


      Their Message is below:


      // Build $headers Variable
      $headers = "From: $from\r\n";
      $headers .= "Content-type: text\r\n";
      $to = "$to";
          // Send the email
          mail($to, $subject, $message, $headers);
          // Assemble the message that goes back to Flash
          // The flash ActionScript is looking for a return variable of "return_msg"
          $my_msg = "Thanks $senderName, your message has been sent.";
          // Print the data back to flash who is patiently waiting for it in the onCompleteHandler
          print "return_msg=$my_msg";
      // Exit script   




      // Set text formatting colors for errors, waiting..., and success mechanisms
      var errorsFormat:TextFormat = new TextFormat();
      errorsFormat.color = 0xFF0000;


      var waitingFormat:TextFormat = new TextFormat();
      waitingFormat.color = 0x001111;


      var successFormat:TextFormat = new TextFormat();
      successFormat.color = 0x3366FF;


      // hide the little processing movieclip
      processing_mc.visible = false;


      // Assign a variable name for our URLVariables object
      var variables:URLVariables = new URLVariables();


      //  Build the varSend variable
      var varSend:URLRequest = new URLRequest("new/contact_parse.php");
      varSend.method = URLRequestMethod.POST;
      varSend.data = variables;


      // Build the varLoader variable
      var varLoader:URLLoader = new URLLoader;
      varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
      varLoader.addEventListener(Event.COMPLETE, completeHandler);


      // Handler for PHP script completion and return
      function completeHandler(event:Event):void{
          // remove processing movieclip
          processing_mc.visible = false;
          // Clear the form fields
          name_txt.text = ".";
          email_txt.text = ".";
          msg_txt.text = "-";
          // Load the response from the PHP file
          status_txt.text = event.target.data.return_msg;


      // Add an event listener for the submit button and what function to run
      submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);


      // Validate form fields and send the variables when submit button is clicked
      function ValidateAndSend(event:MouseEvent):void{
          //validate form fields
          if(!name_txt.length) {   
              status_txt.text = "Please enter your name.";   
          } else if(!email_txt.length) {
              status_txt.text = "Please enter an email address";
          } else if(!validateEmail(email_txt.text)) {
              status_txt.text = "Please enter a VALID email address";
          } else if(!msg_txt.length) {
              status_txt.text = "Please enter a message.";
          } else {
              // All is good so send the message to the parse file
              // Show the little "processing_mc" movieclip
              processing_mc.visible = true;
              // Ready the variables for sending
                variables.userName = name_txt.text;
                 variables.userEmail = email_txt.text;
                 variables.userMsg = msg_txt.text;  


              // Send the data to the php file
              // Put a temporary message in the response field while the PHP file sends back
              // If the code does not connect to the PHP file this message will remain visible to user
              status_txt.text = "Waiting for server connection...";


          } // close else after form validation


      } // Close ValidateAndSend function //////////////////////////////////////////////////////////////


      // Validate email function
      function validateEmail(str:String):Boolean {
          var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
          var result:Object = pattern.exec(str);
          if(result == null) {
              return false;
          return true;

        • 1. Re: Error #2007
          Ned Murphy Adobe Community Professional & MVP

          When you get error messages and post about them, you should include the entire error message in your posting.  In my case I have no idea what a 2007 error involves.  Also, to get the most info into your error messages you should enable the option to Permit Debugging found in the Flash section of the file's Publish Settings.  Selecting that option can often add more details into the error message.

          • 2. Re: Error #2007
            Rootman224 Level 1

            Thanks a lot for the effort and the directions. The contact page is now working correctly.