27 Replies Latest reply on Jan 9, 2011 5:35 PM by kglad

    PHP mail code working when site is live, but with a glitch.

    ITango2

      This code works as it should with the site on the hosting provider EXCEPT it will not go to the next frame (email is received fine) it is however suppose to move to the next frame with a thank you message replacing the form (see second code below it)

       

       

      onClipEvent(load){this.t.v = _root.contacts_txt7;}
      on (rollOver) {this.gotoAndPlay("s1");}
      on (rollOut) {this.gotoAndPlay("s2");}
      on(release){
      _parent.loadVariables("inc/mail.php", "POST");
      }

       

      onClipEvent(data){
      // show thank you screen
      _root.page5.page.nextFrame();
      }

       

      It works as expected in the Flash development environment (though it does not send the e-mail of course since the IDE does not have access to SMTP)

       

      It's a project I've inherited, and not sure why it would work in Flash, but not on the site.

       

      Thanks in advance.

        • 1. Re: PHP mail code working when site is live, but with a glitch.
          kglad Adobe Community Professional & MVP

          is something returned from the php file?


          • 2. Re: PHP mail code working when site is live, but with a glitch.
            ITango2 Level 1

            I assumed from reading on

            OnClipevent

            That it would trigger on the outgoing data.  Is that not true?

             

            If Flash does need a response from the PHP, how would I check the return information?

             

            I'm assuming some sort of statement to display the return info in the program (mind you it would have to be running live on the server to have PHP and mail service available to it).

             

            Thank you for responding.

            • 3. Re: PHP mail code working when site is live, but with a glitch.
              kglad Adobe Community Professional & MVP

              it's not true.

               

              in your data method.

               

               

              p.s.  that's as1 code.  you should, at least, use as2 code and the loadvars class.

              • 4. Re: PHP mail code working when site is live, but with a glitch.
                ITango2 Level 1

                I was aware it was old code, but had figured it was AS 2 since I had the Flash publish settings set to that and it had not complained.

                 

                With all the hours I've put into this I'm wodering if I should scrap the contact us form and start over.

                 

                Another interesting thing is that the code for acting on the clear and submit buttons is in one symbol, and the move to next frame for the thank you is in another (that second code above).

                 

                Would AC in Flash talk accross symbols?

                • 5. Re: PHP mail code working when site is live, but with a glitch.
                  kglad Adobe Community Professional & MVP

                  yes, actionscript can communicate across symbols.

                  • 6. Re: PHP mail code working when site is live, but with a glitch.
                    ITango2 Level 1

                    Can you elaborate on just how to check the return info from the PHP file?  I've spent a number of hours on researching this, and have founf that the PHP mail() function will return true or false.  I'm not sure what is available or a method in Flash to capture AND display that.

                     

                    Thank you.

                    • 7. Re: PHP mail code working when site is live, but with a glitch.
                      kglad Adobe Community Professional & MVP

                      the php file can use "echo" to return data to flash.  it's best to use two loadvars instances:

                       

                       

                      var sendLV:LoadVars=new LoadVars();

                      var receiveLV:LoadVars=new LoadVars();

                       

                      receiveLV.onData=function(src){

                      trace(src);   // everything echo'd by php will trace

                      }

                       

                      function sendF(){

                      sendLV.var1 = whatever;  // send variables/values to php

                      .

                      .

                      sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");

                      }

                      1 person found this helpful
                      • 8. Re: PHP mail code working when site is live, but with a glitch.
                        ITango2 Level 1

                        Thank you very much for that.  I've studied the functions, and have it sending mail out with the below code.  However, the damn onclipevent(data) still wont trigger.  Since my development computer does not have mail or PHP available to it, it's proving difficult to work it out.

                         

                        I did put an echo statement in th PHP file to reflect back a variable, but (to my knowlege) there is no way to see the return while looking at the web site live.

                         

                        It seems that this code would trigger the onclipevent(data)

                         

                        onClipEvent(load){this.t.v = _root.contacts_txt7;}
                        on (rollOver) {this.gotoAndPlay("s1");}
                        on (rollOut) {this.gotoAndPlay("s2");}
                        on(release){
                         
                        var sendLV:LoadVars=new LoadVars();
                        var receiveLV:LoadVars=new LoadVars();

                        receiveLV.onData=function(src){

                        trace(src);   // everything echo'd by php will trace

                        }
                        function sendF(){

                        sendLV.var1 = name;  // send variables/values to php
                        sendLV.var2 = email;
                        sendLV.var3 = phone;
                        sendLV.var4 = message;

                        sendLV.sendAndLoad("inc/mail.php",receiveLV,"POST");


                        }


                        }

                        • 9. Re: PHP mail code working when site is live, but with a glitch.
                          kglad Adobe Community Professional & MVP

                          remove all code for objects.  that's poor coding style and makes debugging more difficult.

                           

                          // assuing t is defined or yourbutton.t is defined:

                          //if you're using a movieclip button:

                          yourbutton.t.v = _root.contacts_txt7;

                          //or if you're using a simple button:

                          t.v=_root.contacts_txt7;

                           

                          yourbutton.onRollOver=function() {this.gotoAndPlay("s1");}
                          yourbutton.onRollOut=function() {this.gotoAndPlay("s2");}
                          yourbutton.onRelease=function(){

                          sendF();

                          }

                           
                          var sendLV:LoadVars=new LoadVars();
                          var receiveLV:LoadVars=new LoadVars();

                          receiveLV.onData=function(src){

                          trace(src);   // everything echo'd by php will trace

                          }


                          function sendF(){

                          sendLV.var1 = name;  // send variables/values to php
                          sendLV.var2 = email;
                          sendLV.var3 = phone;
                          sendLV.var4 = message;

                          sendLV.sendAndLoad("inc/mail.php",receiveLV,"POST");


                          }

                           

                          1 person found this helpful
                          • 10. Re: PHP mail code working when site is live, but with a glitch.
                            ITango2 Level 1

                            Is there a way for Flash to generate a code report?

                             

                            Something like there is code "here" and "there" at least.

                             

                            If I'm going to fix this (and appearently the best thing to do is upgrade to AS2) I might as well go over it all.

                             

                            I also noticed in the AS2 manual that OnCipEvent(data) will only work for LoadVariables, so I'm looking for something else to accomplish that.

                             

                            Again my many thanks for being generouse with your time.

                            • 11. Re: PHP mail code working when site is live, but with a glitch.
                              kglad Adobe Community Professional & MVP

                              yes.  you can use movie explorer, toggle the actionscript button and check all the locations that contain actionscript.

                               

                              don't use LoadVariables, don't use LoadVariablesNum and don't attach code to objects.  use LoadVars and the onData or onLoad methods.

                              • 12. Re: PHP mail code working when site is live, but with a glitch.
                                ITango2 Level 1

                                I wasn't going to use loadvariables, just scratching my head over knowing that the trigger to go to the next frame was not going to work at all since it had been eliminated in that code, and the OnClipEvent(data) needed it........Not that it was working ;-)

                                 

                                I'll look into OnData to trigger.

                                 

                                If code is not "on" an object, what do you suggest?  A "global' area?

                                 

                                From what I've found, the button (  ' t '  movie clip, and ' v ' text var ) are an instance of rd_t

                                 

                                Soooo.

                                 

                                rd_t.t.v ?

                                 

                                Thanks  P.S.  I looked through all the action script in movie explorer and didn't find our code.  Would that be due to it being hung on an object?

                                • 13. Re: PHP mail code working when site is live, but with a glitch.
                                  kglad Adobe Community Professional & MVP

                                  if your button is a simple button you can't assign any properties to it.  if it's a movieclip, you can.

                                   

                                  what's your button?  a movieclip button or simple button?

                                  • 14. Re: PHP mail code working when site is live, but with a glitch.
                                    ITango2 Level 1

                                    Movieclip named   t  (obviously he did not spare the characters)

                                     

                                    overlayed var text is v.

                                     

                                    Thanks

                                    • 15. Re: PHP mail code working when site is live, but with a glitch.
                                      kglad Adobe Community Professional & MVP

                                      then use:

                                       


                                       


                                      t.v = _root.contacts_txt7;


                                       

                                      yourbutton.onRollOver=function() {this.gotoAndPlay("s1");}
                                      yourbutton.onRollOut=function() {this.gotoAndPlay("s2");}
                                      yourbutton.onRelease=function(){

                                      sendF();

                                      }

                                       
                                      var sendLV:LoadVars=new LoadVars();
                                      var receiveLV:LoadVars=new LoadVars();

                                      receiveLV.onData=function(src){

                                      trace(src);   // everything echo'd by php will trace

                                      }


                                      function sendF(){

                                      sendLV.var1 = name;  // send variables/values to php
                                      sendLV.var2 = email;
                                      sendLV.var3 = phone;
                                      sendLV.var4 = message;

                                      sendLV.sendAndLoad("inc/mail.php",receiveLV,"POST");


                                      }

                                       

                                      • 16. Re: PHP mail code working when site is live, but with a glitch.
                                        ITango2 Level 1

                                        I assume I needed the onClipEvent (load) in there as the IDE was complaining.

                                         

                                        It is working and sending out mail, just need to get it to go to that next frame in a message above.

                                        • 17. Re: PHP mail code working when site is live, but with a glitch.
                                          kglad Adobe Community Professional & MVP

                                           


                                           


                                          t.v = _root.contacts_txt7;


                                           

                                          yourbutton.onRollOver=function() {this.gotoAndPlay("s1");}
                                          yourbutton.onRollOut=function() {this.gotoAndPlay("s2");}
                                          yourbutton.onRelease=function(){

                                          sendF();

                                          }

                                           
                                          var sendLV:LoadVars=new LoadVars();
                                          var receiveLV:LoadVars=new LoadVars();

                                          receiveLV.onData=function(src){

                                          _root.page5.page.nextFrame();

                                          }


                                          function sendF(){

                                          sendLV.var1 = name;  // send variables/values to php
                                          sendLV.var2 = email;
                                          sendLV.var3 = phone;
                                          sendLV.var4 = message;

                                          sendLV.sendAndLoad("inc/mail.php",receiveLV,"POST");


                                          }

                                           

                                          • 18. Re: PHP mail code working when site is live, but with a glitch.
                                            ITango2 Level 1

                                            Sigh.

                                             

                                            No go on the frame change.

                                             

                                            I'm going to do the best as I can on describing what I've founf here in this inherited project so I and others are not going in circles.

                                             

                                            The problem area:

                                             

                                            A simple form to receive info of contact information.  Several text boxes, two buttons (reset the form, and send the info),

                                             

                                            Code behind the reset buttton is not a problem, and thanks to KGLAD I have functional AS2 code sending out the mail (although I had to wrap it in onClipEvent(load) to get it to work)  I left it where it was due to seeing the same variables being re-used elsewhere and was concerned about breaking other areas.

                                             

                                            I'm seeing all this functionality however spread between to places in the Action pane

                                             

                                            1.     A symbol "p4_tblock2" with three items Layer 11 frame 1 (contains the text boxes, their borders, as well as the two button areas. Layer 11 frame 2 (contains the desired "Thank you" message.  And "message" (this is not a frame, and contains the now commented out call to move to the next frame that never worked. See code above).

                                             

                                            2.     A symbol "Message" with three items,   "frame 1" which hase code to fill in default text to the text boxes and refill if left blank,  rd1 is there twice (not a frame) and is the two buttons.  Code hehind one of them resets the form to default text, and code behind the other is the fuctioning code from KGLAD.

                                             

                                            I notice that if I click on message in p4_tblock2 a frame appears surrounding all the text blocks.  I'm assuming this is being used to overlay that area with frame 2, the desired effect.

                                             

                                            Thanks for any help, and I would like to openly offer my respects to KGLAD for his patience and help which has exceeded anyones on any forum I've known since beginning to program Fortran on a VAX under VMS using an editor called VI.........some time ago ;-)

                                             

                                            So many languages. so little time.

                                            • 20. Re: PHP mail code working when site is live, but with a glitch.
                                              ITango2 Level 1

                                              <?php
                                              $name=$_POST['name'];
                                              $email=$_POST['email'];
                                              $phone=$_POST['phone'];
                                              $message=$_POST['message'];

                                              $ToEmail = "removed.com";
                                              $ToSubject = "Message from web site";

                                              $EmailBody =   "Name: $name\n
                                                  Email: $email\n
                                                  Phone: $phone\n
                                                  Message: $message\n";

                                              $Message = $EmailBody;

                                              $headers .= "Content-type: text; charset=iso-8859-1\r\n";
                                              $headers .= "From:". $name . " <" . $email . ">\r\n";


                                              mail($ToEmail, $ToSubject, $Message, $headers);

                                               

                                              ?>

                                              • 21. Re: PHP mail code working when site is live, but with a glitch.
                                                kglad Adobe Community Professional & MVP

                                                there's nothing being sent to your flash.

                                                 

                                                use:

                                                 

                                                 

                                                 

                                                <?php
                                                $name=$_POST['name'];
                                                $email=$_POST['email'];
                                                $phone=$_POST['phone'];
                                                $message=$_POST['message'];

                                                $ToEmail = "removed.com";
                                                $ToSubject = "Message from web site";

                                                $EmailBody =   "Name: $name\n
                                                    Email: $email\n
                                                    Phone: $phone\n
                                                    Message: $message\n";

                                                $Message = $EmailBody;

                                                $headers .= "Content-type: text; charset=iso-8859-1\r\n";
                                                $headers .= "From:". $name . " <" . $email . ">\r\n";


                                                $success = mail($ToEmail, $ToSubject, $Message, $headers);

                                                echo $success;

                                                ?>

                                                • 22. Re: PHP mail code working when site is live, but with a glitch.
                                                  ITango2 Level 1

                                                  Still no joy.

                                                   

                                                  Mail works fine, but it's as if (as you say) nothing is comming back.

                                                  • 23. Re: PHP mail code working when site is live, but with a glitch.
                                                    kglad Adobe Community Professional & MVP

                                                    continuing to use that php script, use the following actionscript and post a link to your url:

                                                     

                                                     

                                                    t.v = _root.contacts_txt7;

                                                     

                                                     

                                                    yourbutton.onRollOver=function() {this.gotoAndPlay("s1");}
                                                    yourbutton.onRollOut=function() {this.gotoAndPlay("s2");}
                                                    yourbutton.onRelease=function(){

                                                    sendF();

                                                    }

                                                     
                                                    var sendLV:LoadVars=new LoadVars();

                                                    var receiveLV:LoadVars=new LoadVars();

                                                    receiveLV.onData=function(src){

                                                    trace(src);

                                                    trace(_root.page5.page);

                                                    _root.page5.page.nextFrame();

                                                    }


                                                    function sendF(){

                                                    sendLV.var1 = name;  // send variables/values to php
                                                    sendLV.var2 = email;
                                                    sendLV.var3 = phone;
                                                    sendLV.var4 = message;

                                                    sendLV.sendAndLoad("inc/mail.php",receiveLV,"POST");


                                                    }

                                                    • 24. Re: PHP mail code working when site is live, but with a glitch.
                                                      ITango2 Level 1

                                                      As before, the compiler complains numerous times about the statements needing to be within the onClipEvent handler.  Or was that implied?

                                                      • 25. Re: PHP mail code working when site is live, but with a glitch.
                                                        kglad Adobe Community Professional & MVP

                                                        no code should be attached to any movieclip or button.  fix that.

                                                        • 26. Re: PHP mail code working when site is live, but with a glitch.
                                                          ITango2 Level 1

                                                          Agreeing that the problem was due to Flash not getting any return info I decided to move the site to another server on the net and somewhat start over.  My test server in house does not have an e-mail server, and of course the PHP mail() function will not authorise to a remote one.  In house I was using a simple SMTP only server  to send out the e-mail which was working (sending).  I suspect one of two problems or both.

                                                           

                                                          1.     These smtp servers were note sending a sucess back after the sending of mail (assuming the PHP mail function needed a return).

                                                           

                                                          2.     All of the reading I've done indicates that the PHP mail() function is a bit problematic, and IT was not sending a sucess back to flash.

                                                           

                                                          At this point I've installed "phpmailer" class on the new remote sever and the flash site and it is sending mail reliably (and Flash advances to the "Thank You" frame) with KGLADs code above.  However, the variables sent to PHP (name phone, etc) are empty, and I've confirmed that with a breakpoint and examination of var1 etc.  Changing var1 to a literal string does arrive in the sent e-mail.

                                                           

                                                          I'm assuming it has to do with the AC code being hung on a movie clip and wrapped in onEvent (load), so I'm going to mark this as answered and start another thread on how to clean up what I have which is spanning two simbols, and several layers and frames in both.

                                                           

                                                          On a side note, I'd like to suggest to all that want to use PHP mail functions from Flash on a Windows server to NOT use mail() the phpmailer is a lot more functional.

                                                           

                                                          Thanks to KGLAD

                                                           

                                                           

                                                          • 27. Re: PHP mail code working when site is live, but with a glitch.
                                                            kglad Adobe Community Professional & MVP

                                                            i think using the following is reliable:

                                                             

                                                             

                                                            if(mail($emailRecipient, $emailSubject, $emailBody, $emailHeaders)){
                                                              echo "success";
                                                            } else {
                                                              echo "failure";
                                                            }