1 2 Previous Next 40 Replies Latest reply on Nov 5, 2007 5:41 PM by Stan20000

    Email Form Validation-Flash 8 Professional

    janst


      I have been looking at this too long now! I need to ask for help.

      I have a simple email form - Name-Company name-telephone-email-message

      The code that I have on the send button is this:
      quote:


      on (press) {
      // Make sure the user filled in all the required fields.
      if (sender_name eq "" and sender_email eq "" and message eq "") {
      // Check to make sure the email address includes and @.
      i = "0";
      validmail = 0;
      while (Number(i)<=Number(length(sender_email))) {
      if (substring(sender_email, i, 1) eq "@") {
      validmail = 1;
      }
      i = Number(i)+1;
      }
      // If there's no @ in the email go to the error page.
      if (Number(validmail) == 0) {
      gotoAndStop("novalidmail");
      } else {
      gotoAndStop("ready");
      }
      } else {
      // if the user left required fields blank, show them an error message.
      gotoAndStop("ready");
      }
      }


      I have this text appearing on a separate page for the sender to view before hitting the send button. The problem that I am encountering is that the text in the viewer's text box is as it should be but it says "undefined" throughout... I keep checking to make sure that the text boxes all have the correct Var name and they do...

      Any idea why I would be getting this "undefined" throughout the text being read back?

      THANKS!
        • 1. Email Form Validation-Flash 8 Professional
          janst Level 1
          I forgot to mention...

          The text field that the information is going to has this code:
          quote:


          messageContent = "Hello" + "sender_name " <br> + " company " <br> + "Telephone " <br> + "The e-mail message that you are sending reads as follows: " <br> + "Your E-mail is: " + sender_email;
          stop();


          • 2. Re: Email Form Validation-Flash 8 Professional
            janst Level 1
            I figured it out!!! Oh, wow!!! This was so simple and I just wasn't getting it...

            the code for the text box should be:
            quote:


            "Hello" + "sender_name " + newline + " company " + newline + "Telephone " + newline + "The e-mail message that you are sending reads as follows: " + newline + "Your E-mail is: " + newline + sender_email;
            stop();



            and I was using code from an older site that I made and the "and" should have been "+" for the send button.
            • 3. Re: Email Form Validation-Flash 8 Professional
              clbeech Level 3
              well it's difficult to say what the problem with the fields is from the information you've provided, this code has to do with the checks you are performing, and not the assignments of any textFields. However, I see several syntax errors, and would suggest that you write this differently. Why is this code on the 'send' button, when it's not sending anything yet, and how are you planning on actually sending the email? Do you know that to do so will require the use of a server-side script like php, and do you have one prepared? Also, do you know you will need to use the LoadVars class to do the sending?

              You should not be using the variable 'i' which you are you as a numeric value, but assigning it as a String, you should be simply using it as a Number. You also must have this code attached to the button, you should do this from the main timeline instead. You have also been checking to see if the value of 'sender_name' and the others are EQUAL to null? I think what you want to do is to make sure they are NOT equal to null. Also you do not need to loop through the email string to determine if it contains the '@' symbol, use String.indexOf instead as below. rewrite the code more like this:
              • 4. Re: Email Form Validation-Flash 8 Professional
                janst Level 1
                quote:

                Originally posted by: clbeech
                well it's difficult to say what the problem with the fields is from the information you've provided, this code has to do with the checks you are performing, and not the assignments of any textFields. However, I see several syntax errors, and would suggest that you write this differently. Why is this code on the 'send' button, when it's not sending anything yet, and how are you planning on actually sending the email? Do you know that to do so will require the use of a server-side script like php, and do you have one prepared? Also, do you know you will need to use the LoadVars class to do the sending?

                You should not be using the variable 'i' which you are you as a numeric value, but assigning it as a String, you should be simply using it as a Number. You also must have this code attached to the button, you should do this from the main timeline instead. You have also been checking to see if the value of 'sender_name' and the others are EQUAL to null? I think what you want to do is to make sure they are NOT equal to null. Also you do not need to loop through the email string to determine if it contains the '@' symbol, use String.indexOf instead as below. rewrite the code more like this:



                Thank you,

                Your solution is much more streamlined. I am always trying to write more code than I need to write.

                Thank you very much!!!

                Also, there was an error with the other part. The working code for the receiving text box looks like this:

                quote:



                messageContent = "Hello" + sender_name + newline + company + newline + telephone + newline + "Your E-mail is: " + newline + sender_email + newline + "The e-mail message that you are sending reads as follows: " + newline + message;
                stop();

                • 5. Re: Email Form Validation-Flash 8 Professional
                  clbeech Level 3
                  you're welcome.

                  OK so now you have a concatenated string variable, named 'messageContent', and I'm assuming that 'newline' = '\n' and that this is being assigned to a textfield on a 'confirmation page' before sending. Is this correct?

                  Now, how are you planning to send the email message to the recipient?
                  • 6. Re: Email Form Validation-Flash 8 Professional
                    janst Level 1
                    quote:

                    Originally posted by: clbeech
                    you're welcome.

                    OK so now you have a concatenated string variable, named 'messageContent', and I'm assuming that 'newline' = '\n' and that this is being assigned to a textfield on a 'confirmation page' before sending. Is this correct?

                    Now, how are you planning to send the email message to the recipient?


                    The code that I wrote refers to a text box that has a "back" button underneath it to edit the text and a "send" button next to that if the text is correct and needs to be sent... that goes to a PHP file.

                    • 7. Re: Email Form Validation-Flash 8 Professional
                      janst Level 1
                      Chain of events:

                      user fills out form that has "clear" and "send" button underneath

                      if not validated, goes to a warning screen with "back" button

                      if validated, goes to large text box with a sample of the information being sent

                      underneath THAT text box is a back but to edit or a send button to send

                      the user then goes to a screen saying thank you
                      • 8. Re: Email Form Validation-Flash 8 Professional
                        clbeech Level 3
                        great, sounds good. So do you now have all of the sender's information variables assigned to LoadVars, and do you have the php ready to parse these and send them within an email?
                        • 9. Re: Email Form Validation-Flash 8 Professional
                          janst Level 1
                          I couldn't get this working with the middle "show message" step... the message just kept getting cut off at the end so I changed the code for the form to read like this:

                          • 10. Re: Email Form Validation-Flash 8 Professional
                            janst Level 1
                            It's not working...

                            My PHP script looks like this:
                            I have the variables filled in the real script.
                            • 11. Email Form Validation-Flash 8 Professional
                              janst Level 1


                              Can anyone please help?

                              -J
                              • 12. Re: Email Form Validation-Flash 8 Professional
                                clbeech Level 3
                                Hey Janst, OK I don't think that the variables are getting through quite right, The Meesage String you have above is not formatted so that the php can iterate through the infomation, and I don't see anything in the php code that is referencing the $_POST['var'] (or the posted variable) I also think you should use the LoadVars class. each piece of textfield info should get assigned to a variable being sent with the Loadvar, then those should be retrieved and used to fomat the mail message the way you would like. So to get started, examine the methods I use in this simple example of the LoadVars class and PHP email, then we'll work at formatting thing the way you need them to output.

                                Here's the files: FILES
                                • 13. Re: Email Form Validation-Flash 8 Professional
                                  janst Level 1
                                  quote:

                                  Originally posted by: clbeech
                                  Hey Janst, OK I don't think that the variables are getting through quite right, The Meesage String you have above is not formatted so that the php can iterate through the infomation, and I don't see anything in the php code that is referencing the $_POST['var'] (or the posted variable) I also think you should use the LoadVars class. each piece of textfield info should get assigned to a variable being sent with the Loadvar, then those should be retrieved and used to fomat the mail message the way you would like. So to get started, examine the methods I use in this simple example of the LoadVars class and PHP email, then we'll work at formatting thing the way you need them to output.

                                  Here's the files: FILES


                                  THANK YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                                  I am looking at it right now...
                                  • 14. Email Form Validation-Flash 8 Professional
                                    janst Level 1
                                    quote:

                                    Originally posted by: clbeech
                                    Hey Janst, OK I don't think that the variables are getting through quite right, The Meesage String you have above is not formatted so that the php can iterate through the infomation, and I don't see anything in the php code that is referencing the $_POST['var'] (or the posted variable) I also think you should use the LoadVars class. each piece of textfield info should get assigned to a variable being sent with the Loadvar, then those should be retrieved and used to fomat the mail message the way you would like. So to get started, examine the methods I use in this simple example of the LoadVars class and PHP email, then we'll work at formatting thing the way you need them to output.

                                    Here's the files: FILES


                                    How do I incorporate:
                                    if(sender_name != null && sender_email != null && message != null && sender_email.indexOf('@') > 0) {
                                    loadVariablesNum("send_email.php", 0, "POST");
                                    gotoAndStop('sent');
                                    }else{
                                    gotoAndStop('novalidmail');
                                    • 15. Email Form Validation-Flash 8 Professional
                                      clbeech Level 3
                                      OK, first you need to set up the LoadVar, in the example I've used 'email_lv', so let's set up a function to handle the mailing. like this:
                                      • 16. Re: Email Form Validation-Flash 8 Professional
                                        janst Level 1
                                        Oh, I was trying to do the variables and validation in reverse...

                                        I'm going to try this

                                        Thanks!
                                        • 17. Re: Email Form Validation-Flash 8 Professional
                                          janst Level 1
                                          quote:

                                          Originally posted by: clbeech
                                          OK, first you need to set up the LoadVar, in the example I've used 'email_lv', so let's set up a function to handle the mailing. like this:



                                          I can't get this to send mail... I checked the web host and it says it is configured for PHP Version 4.3.11 ...

                                          Is it better to write to the send mail in the CGI bin?
                                          • 18. Re: Email Form Validation-Flash 8 Professional
                                            SymTsb Level 2
                                            email.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST");

                                            should be

                                            email_lv.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST");
                                            • 19. Re: Email Form Validation-Flash 8 Professional
                                              janst Level 1
                                              quote:

                                              Originally posted by: SymTsb
                                              email.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST")

                                              should be

                                              email_lv.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST")





                                              Thank you!!!!

                                              • 20. Re: Email Form Validation-Flash 8 Professional
                                                janst Level 1
                                                quote:

                                                Originally posted by: SymTsb
                                                email.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST");

                                                should be

                                                email_lv.sendAndLoad(" http://www.yourdomain.com/send_email.php", return_lv, "POST");



                                                Well,

                                                I changed this... must be something else... still no mail...

                                                Oh, well....

                                                I have to get this working...
                                                • 21. Re: Email Form Validation-Flash 8 Professional
                                                  clbeech Level 3
                                                  @ SymTsb: thanks, missed that in the typing I guess :)

                                                  @Janst: you did change all of the info needed right, as to domain names and other items in the php, in particular the '$to' var, to an email address that you have to check with? try using a trace statements to see if your getting a return from the php, place it in the onLoad handler.

                                                  Also is the php mounted in the root directory on your online server? It could be anywhere but the path needs to be correct, the code above would be for the root level.
                                                  • 22. Re: Email Form Validation-Flash 8 Professional
                                                    janst Level 1
                                                    quote:

                                                    Originally posted by: clbeech
                                                    @ SymTsb: thanks, missed that in the typing I guess :)

                                                    @Janst: you did change all of the info needed right, as to domain names and other items in the php, in particular the '$to' var, to an email address that you have to check with? try using a trace statements to see if your getting a return from the php, place it in the onLoad handler.

                                                    Also is the php mounted in the root directory on your online server? It could be anywhere but the path needs to be correct, the code above would be for the root level.


                                                    Yes, I did all those things. Its crazy. I have built a number of these email forms with older versions of Flash. I must be looking at this thing upside down! My Google home page has the following horoscope for me today. It really made me laugh!
                                                    quote:

                                                    As your visions expand today, you could gloss over data that you don't have time to integrate. This may cause you to miss something very important. Listen extra carefully to advice from friends, whether it was solicited or not -- for it can help you gain clarity. If you don't receive offers for assistance, don't be afraid to ask for it. You need your reality checked now by someone who can see things more objectively.


                                                    • 23. Re: Email Form Validation-Flash 8 Professional
                                                      clbeech Level 3
                                                      lol!! :) that's rich! Say can you post your files, maybe I could take a look and try a few things today.
                                                      • 24. Re: Email Form Validation-Flash 8 Professional
                                                        janst Level 1
                                                        quote:

                                                        Originally posted by: clbeech
                                                        lol!! :) that's rich! Say can you post your files, maybe I could take a look and try a few things today.


                                                        I'm doing one last rebuild... I'll post those when I'm done.

                                                        THANK YOU!!
                                                        • 25. Re: Email Form Validation-Flash 8 Professional
                                                          janst Level 1
                                                          quote:

                                                          Originally posted by: clbeech
                                                          lol!! :) that's rich! Say can you post your files, maybe I could take a look and try a few things today.


                                                          Okay, how do I send you the files?

                                                          • 26. Re: Email Form Validation-Flash 8 Professional
                                                            janst Level 1
                                                            quote:

                                                            Originally posted by: janst
                                                            quote:

                                                            Originally posted by: clbeech
                                                            lol!! :) that's rich! Say can you post your files, maybe I could take a look and try a few things today.


                                                            Okay, how do I send you the files?




                                                            • 27. Email Form Validation-Flash 8 Professional
                                                              janst Level 1
                                                              Thanks for helping
                                                              • 28. Re: Email Form Validation-Flash 8 Professional
                                                                janst Level 1
                                                                Okay,

                                                                Why is this not working?
                                                                This is what I am writing...

                                                                • 29. Re: Email Form Validation-Flash 8 Professional
                                                                  janst Level 1
                                                                  Okay,

                                                                  A new day and a new start...
                                                                  • 30. Re: Email Form Validation-Flash 8 Professional
                                                                    janst Level 1
                                                                    Anyone see mistakes here?

                                                                    I appreciate it!

                                                                    Thanks!
                                                                    • 31. Re: Email Form Validation-Flash 8 Professional
                                                                      janst Level 1
                                                                      I am having success having the email sent using the following code:

                                                                      • 32. Re: Email Form Validation-Flash 8 Professional
                                                                        janst Level 1
                                                                        I am having 2 problems with this.

                                                                        1) the email is sent with the word "false" in front of the name... okay i figured that out... PHP thing

                                                                        2) the form is not in plain text even though I did not check the html selection for the text boxes
                                                                        -----------------------------------------------------------------------------
                                                                        How do I have the email come to me in plain text?
                                                                        • 33. Re: Email Form Validation-Flash 8 Professional
                                                                          janst Level 1
                                                                          Hi,

                                                                          I just wanted to post a final comment on the email form that I finally successfully built.
                                                                          I was AMAZED at the number of email forms as downloads and tutorials there are on the web. There were only a few that were working fully. I found most of them had something that was somewhat faulty in either the fla part or the PHP part... Some of it had to due with various versions of Flash and PHP.

                                                                          I ended up following the lead of clbeech (THANK YOU VERY MUCH!)... (also thank you SymTsb!)

                                                                          I am going to post the code that I used so that others who are working with Flash 8 have a guideline to follow. Of course, as soon as I update to AS3, I'll have to do something else!

                                                                          It would be great if Flash would come with an email form as a component. The user would of course have to supply their own PHP, Perl, or whatever script but that's ok.

                                                                          ---------------------------------------ActionScript--------------------------------------- -------------
                                                                          • 34. Re: Email Form Validation-Flash 8 Professional
                                                                            Level 7
                                                                            Thanks

                                                                            This worked for me also, instead of php i have a aspx file for sending the
                                                                            mail

                                                                            Thanks
                                                                            JohnL

                                                                            "janst" <webforumsuser@macromedia.com> wrote in message
                                                                            news:fcrvcc$6o8$1@forums.macromedia.com...
                                                                            > Hi,
                                                                            >
                                                                            > I just wanted to post a final comment on the email form that I finally
                                                                            > successfully built.
                                                                            > I was AMAZED at the number of email forms as downloads and tutorials there
                                                                            > are
                                                                            > on the web. There were only a few that were working fully. I found most of
                                                                            > them
                                                                            > had something that was somewhat faulty in either the fla part or the PHP
                                                                            > part... Some of it had to due with various versions of Flash and PHP.
                                                                            >
                                                                            > I ended up following the lead of clbeech (THANK YOU VERY MUCH!)... (also
                                                                            > thank you SymTsb!)
                                                                            >
                                                                            > I am going to post the code that I used so that others who are working
                                                                            > with
                                                                            > Flash 8 have a guideline to follow. Of course, as soon as I update to AS3,
                                                                            > I'll
                                                                            > have to do something else!
                                                                            >
                                                                            > It would be great if Flash would come with an email form as a component.
                                                                            > The
                                                                            > user would of course have to supply their own PHP, Perl, or whatever
                                                                            > script but
                                                                            > that's ok.
                                                                            >
                                                                            >
                                                                            > ---------------------------------------ActionScript-----------------------------
                                                                            > -----------------------
                                                                            >
                                                                            > stop();
                                                                            >
                                                                            > send_btn.onPress = function() {
                                                                            > if(sender_name != null && sender_email != null && message != null &&
                                                                            > sender_email.indexOf('@') > 0) {
                                                                            > gotoAndStop('sent');
                                                                            > sendMail();
                                                                            > }else{
                                                                            > gotoAndStop('novalidmail');
                                                                            > }
                                                                            > }
                                                                            >
                                                                            > var email_lv:LoadVars = new LoadVars();
                                                                            > var return_lv:LoadVars = new LoadVars();
                                                                            > function sendMail() {
                                                                            > email_lv.sender_name = sender_name;
                                                                            > email_lv.company = company;
                                                                            > email_lv.telephone = telephone;
                                                                            > email_lv.sender_email = sender_email;
                                                                            > email_lv.message = message;
                                                                            > return_lv.onLoad = function() {
                                                                            > if(return_lv.confirm) {
                                                                            > gotoAndStop('sent');
                                                                            > }
                                                                            > }
                                                                            > email_lv.sendAndLoad("sendemail.php", return_lv, "POST");
                                                                            > }
                                                                            >
                                                                            > ---------PHP
                                                                            > code------------------------------------------------------------------------
                                                                            >
                                                                            > <?php
                                                                            > $mailheaders = "From: Company Contact Form\r\nContent-type: text/html";
                                                                            >
                                                                            > $msg = "<b>E-mail sent from Our Company Web Site</b><p></p>";
                                                                            > $msg .= "<b>From Name:</b> ".$_POST['sender_name']."<p></p>";
                                                                            > $msg .= "<b>Company Name:</b> ".$_POST['company']."<p></p>";
                                                                            > $msg .= "<b>Telephone:</b> ".$_POST['telephone']."<p></p>";
                                                                            > $msg .= "<b>From E-Mail:</b> ".$_POST['sender_email']."<p></p>";
                                                                            > $msg .= "<b>Message:</b> ".$_POST['message'];
                                                                            >
                                                                            > $to = "name@company.com,name2@company.com";
                                                                            > $subject = "Request for Information";
                                                                            >
                                                                            > mail($to, $subject, $msg, $mailheaders);
                                                                            >
                                                                            > echo('confirm=true');
                                                                            > ?>
                                                                            >


                                                                            • 35. Email Form Validation-Flash 8 Professional
                                                                              markad007
                                                                              Can you load up the complete code that ended up working for you? Action Script and PHP. I am pretty much coping your work. I don't have as many fields, but I know I am close to having this form working.

                                                                              Thanks so much!
                                                                              Mark
                                                                              • 36. Re: Email Form Validation-Flash 8 Professional
                                                                                markad007 Level 1
                                                                                janst,
                                                                                Gosh...It would help if I just kept reading through your post. Never mind my previous post. I must be tired...

                                                                                JohnL
                                                                                I want to try the PHP first, but if I can't get that to work I sure will try the aspx.

                                                                                Thanks,
                                                                                Mark
                                                                                • 37. Re: Email Form Validation-Flash 8 Professional
                                                                                  janst Level 1
                                                                                  Hi John,

                                                                                  Just make sure that you put the Actionscript code on the frame of the submit button instead of the button itself. Also, make sure that the var field for each text field is filled out with the name referenced in the scripts.

                                                                                  This form does not work sending to an aol address.

                                                                                  In this line : bt_send.onPress = function() {

                                                                                  'bt_send" is the instance name of the submit button...
                                                                                  • 38. Re: Email Form Validation-Flash 8 Professional
                                                                                    clbeech Level 3
                                                                                    Hey Janst, I'm so glad to hear that you were able to get your system to function properly. I'm very sorry I'd abondoned you, my computer crashed, and I nearly lost everything, I finally did recover my files though ... whew!

                                                                                    Congrads! And you're welcome :)
                                                                                    • 39. Re: Email Form Validation-Flash 8 Professional
                                                                                      janst Level 1
                                                                                      quote:

                                                                                      Originally posted by: clbeech
                                                                                      Hey Janst, I'm so glad to hear that you were able to get your system to function properly. I'm very sorry I'd abondoned you, my computer crashed, and I nearly lost everything, I finally did recover my files though ... whew!

                                                                                      Congrads! And you're welcome :)


                                                                                      No need to apologize... you helped me alot! I learned quite a bit working on this form.
                                                                                      Thanks again!
                                                                                      1 2 Previous Next