19 Replies Latest reply on Jan 3, 2008 11:30 AM by markad007

    Flash 8 AS and PHP email form

    markad007
      Hi,

      I am finally finding some time over the holidays to work on my website flash email form. I have had some wonderful help from kglad and Chris a couple of months ago. I will attach my AS2 code first and then my PHP code I have recieved from Yahoo. (Our hosting server for the website).

      I keep getting my error message of... "Sorry, there was a server error, please try again."

      I also have specified the default mail account within my yahoo small business web account under PHP/Perl Mail Setup markd@invisionequity.com as the Default.

      Any help would be greatly appreciated, and thank you in advance!

        • 1. Re: Flash 8 AS and PHP email form
          kglad Adobe Community Professional & MVP
          where's that error message being generated?
          • 2. Re: Flash 8 AS and PHP email form
            Level 7
            $_POST_VARS is not correct... there's an http_post_vars, but you don't want
            to use that either. Just use $_POST.

            And you can get rid of the "POST" in your sendAndLoad - it is the default,
            and it uses GET in the IDE anyway.

            So if you want it to work during testing, from the Flash IDE, you'll want to
            use $_REQUEST in your PHP, because Flash sends with GET, not POST, unless
            you're in the browser. When you are done testing, and put it online, then
            change the $_REQUEST to $_POST. No need to change anything in AS.

            --
            Dave -
            Head Developer
            http://www.blurredistinction.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/


            • 3. Re: Flash 8 AS and PHP email form
              markad007 Level 1
              from Flash 8.
              • 4. Re: Flash 8 AS and PHP email form
                markad007 Level 1
                I've corrected the $_POST_VARS to $_POST.

                I am not seeing this?
                And you can get rid of the "POST" in your sendAndLoad - it is the default,
                and it uses GET in the IDE anyway.
                • 5. Re: Flash 8 AS and PHP email form
                  Greg Dove Level 4
                  Your php script is not designed for flash.

                  Flash expects a confirm=1 response (or something like that) and its getting:
                  <h4>Thank you for sending email</h4>

                  or :
                  <h4>Can't send email to $email</h4>
                  (with $email replaced by its value)

                  instead. So even if it worked correctly it, flash will assume its an error based on the code you have.

                  You need to change all the echos in you php to return something meaningful to the return_lv LoadVars instance
                  • 6. Flash 8 AS and PHP email form
                    Greg Dove Level 4
                    And - I'm assuming also - remove the other whitespace that might be output and the head, body and html tags. Someone recently said that wasn't necessary, but I've never tried it. I always just send back urlencoded name/value pairs because I know that's what LoadVars expects
                    • 7. Re: Flash 8 AS and PHP email form
                      markad007 Level 1
                      I have reinstated the original PHP file that Chris from this forum helped me with and ditched the PHP file from Yahoo support.

                      Please see code attached...
                      • 8. Re: Flash 8 AS and PHP email form
                        Greg Dove Level 4
                        ah, ok... that looks a lot better.

                        Is that working ok then?

                        Do you mean Chris Beech who helped you last time? If so, I know he's been busy recently and hasn't had much time in this forum, although I'm sure he'll be back. If it is him and he's familiar with the issue, you might get his attention in flashgods.org forums or live chat.
                        • 9. Re: Flash 8 AS and PHP email form
                          markad007 Level 1
                          I test out the new .swf and Chris's .php file on my site and it is still giving me an error message. :(

                          http://www.invisionequity.com/htmlpages/contactinfo.html

                          Yes,
                          Chris Beech was helping me a while back. We were at a stopping point. We thought it might be a Yahoo Hosting thing? Still not sure why this .swf and .php won't work together?

                          I have also specified the default mail account within my yahoo small business web account under PHP/Perl Mail Setup to have markd@invisionequity.com as the Default. (This email is for testing) The live email address for online useres will be info@invisionequity.com.
                          • 10. Re: Flash 8 AS and PHP email form
                            Greg Dove Level 4
                            I just tested it and it gave me a positive on-screen message.
                            "Thank you your message has been received".
                            Probably you might want to make form 'disappear' and make the confirmation message more prominent in flash. But the way things are set up in php that will now happen whether the email was successfully sent or not. The confirm=true means that your script was executed.

                            Did I receive the email? No. At least not yet. So that means that the problem is with the php side of things.

                            in your php try:
                            $result=mail($to, $subject, $msg, $mailheaders);

                            echo "confirm=".$result;

                            I suspect that will return 0 or false because I'm guessing the mail part is not working on the server.
                            • 11. Re: Flash 8 AS and PHP email form
                              markad007 Level 1
                              I changed the following in the PHP... and uploaded to site. Now the .swf is giving an error message again.

                              • 12. Re: Flash 8 AS and PHP email form
                                Greg Dove Level 4
                                great (in a way), so now you can be sure the problem is that the php mail function is not working correctly, the flash part is working fine.

                                I'll take a quick look at the php docs and see if I can see anything obvious...
                                • 13. Re: Flash 8 AS and PHP email form
                                  markad007 Level 1
                                  GWD,

                                  Thanks so much! I am so grateful for the help.
                                  • 14. Re: Flash 8 AS and PHP email form
                                    Greg Dove Level 4
                                    Let me prefix this by saying...
                                    I haven't used an email script directly... I've always used an intemediate function when I've been doing things like this through a CMS or whatever.. so that's my way of saying I'm not sure of this...

                                    But
                                    I see two potential things with the mail function based on the php docs.

                                    1. the msg string.
                                    According to this:
                                    Each line should be separated with a LF (\n). Lines should not be larger than 70 characters.

                                    You don't seem to have that. I know its html formatted... but perhaps you should put the LF chars in.

                                    2. This is probably far less likely and only try it after the first option above (I'm guessing this is very rare):
                                    For your message headers where you have \r\n
                                    Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.



                                    • 15. Re: Flash 8 AS and PHP email form
                                      Greg Dove Level 4
                                      Hmmm, well after looking at some of the examples on this page

                                      http://www.php.net/manual/en/function.mail.php

                                      It doesn't seem so important perhaps to use the \n chars in the message... there's an html example there without them.

                                      So I may be on the wrong track there. I'm at the extent of my knowledge there and can't help any further sorry.
                                      • 16. Re: Flash 8 AS and PHP email form
                                        markad007 Level 1
                                        GWD,

                                        Thanks so much for all your efforts on this question. It is greatly appreciated!
                                        • 17. Re: Flash 8 AS and PHP email form
                                          Greg Dove Level 4
                                          no problems. If I were working on this from this point on I would just code a test php script to send an email and try to get that part working separately. Just put fixed values in for the to, subject and message etc. You can call it from the browser while you're testing it and you will just see 'confirm=true' or confirm=false appear as the response in the browser (maybe it will be 1 or 0).
                                          I would use some of the simple examples from the php docs page and/or go back to your yahoo example. Once you've got that working then integrate the flash part back in.
                                          • 18. Flash 8 AS and PHP email form
                                            clbeech Level 3
                                            Hey Mark! sorry I've been out of the loop for a while :) very busy. and thanks for helping out guys, especially gwd.

                                            I think I may see the problem here, in your response from yahoo, they had indicated that the 'FROM:' field was miss-directed not a non-domain address. and from the latest php here, I see that you'd not changed the info in that field. let's try changing the line to this:

                                            $mailheaders = "From: mark@invisionequity.com\r\nContent-type: text/html"

                                            and the rest of the php back to the original return for the swf.
                                            cross you fingers :)
                                            • 19. Re: Flash 8 AS and PHP email form
                                              markad007 Level 1
                                              Thanks to everyone! After lots of hard work by many on this forum this question has been aswered. Thank you clbeech!