A Flash Developer Resource Site

Results 1 to 20 of 20

Thread: [RESOLVED] php mailer with scrolling comment input box

  1. #1
    Junior Member
    Join Date
    Nov 2005
    Posts
    28

    [RESOLVED] php mailer with scrolling comment input box

    Hello,

    I am using the PHP Mailer by 88Kilo in the movies section.
    http://www.flashkit.com/movies/Inter...1390/index.php

    However, I had to change it so that the comments box had a scroll bar. To do this, I had to put the comments input text box, which is labeled Var:comments into a separate movie clip. Now it scrolls and my email sends, but it doesn't send anything you type in the comments box. I think there is a problem with my routing...somehow I need to tell the mailer to look within the movie clip (instance name: myInput) for the Var:comments.

    Here is the code in the actions layer on the root timeline:

    stop();
    // this variable will decide if the email address is in the correct format
    a =0;
    // validates the email field for @ symbol and a . at the end
    function validate () {
    if (from.length>=7) {
    if (from.indexOf("@")>0) {
    if ((from.indexOf("@")+2)<from.lastIndexOf(".")) {
    if (from.lastIndexOf(".")<(from.length-2)) {
    a = 1;
    // email is fine
    }
    }
    }
    }

    }
    // checks for empty fields then calls email check function
    function formcheck () {
    validate ();
    trace(a);
    if (fname = "" or telno eq "" or comments eq "" or from eq "") {
    stop();
    error = "You have left blank fields, please fill in all fields, thank you";
    } else {
    emailcheck ();
    }
    }
    // email check function calls the fucntion at the top, if its satisfied it loads the php script and sends you to frame 2
    function emailcheck (){
    if (a != 1){
    stop();
    error = "Email address not valid";
    } else {
    loadVariablesNum("mail.php3", 0, "POST");
    gotoAndStop(2);
    }
    }

    Here is the code from the .php page:

    <?php

    $adminaddress = "myemail@email.com";
    $sitename = "Website.com";

    mail("$adminaddress","Info Request",

    "A Message from $sitename from\n

    First Name: $name

    Company Name: $company
    Telephone: $telno

    Email: $from\n

    The visitor commented:

    -----------------------------------------------------------------------------------------

    $comments



    Logged Info :

    -----------------------------------------------------------------------------------------

    Using: $HTTP_USER_AGENT

    Hostname: $ip

    IP address: $REMOTE_ADDR

    Date/Time: $date","FROM:$adminaddress");


    ?>

    Any help is greatly appreciated.

    PippyLu

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You are not using flash 8 , since you use "eq" instead "==" in the if statement. Better change that, since in Flash 8 eq is not allowed.

    The reference to the textfield should be

    myInput.comments
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Nov 2005
    Posts
    28
    I changed this line in the flash file:
    if (fname = "" or telno eq "" or comments eq "" or from eq "") {
    to
    if (fname = "" or telno == "" or myInput.comments == "" or from == "") {
    but I still get the same result, the message sends with the comments area empty.

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    That tutorial is very old (Flash 5). I would not use it in the present form. loadVariablesNum has several problems and one of them is dealing with levels. I changed the fla including LoadVars and including your new movieclip.
    Attached Files Attached Files
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Junior Member
    Join Date
    Nov 2005
    Posts
    28
    Awesome! Thanks! It works...with one little glich. When you click Send it now launches mail.php3 in a new blank window. How can I make this not happen?

  6. #6
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Change the code to this:

    PHP Code:
    function emailcheck ()
    {
        var 
    lv:LoadVars = new LoadVars ();
        var 
    lvAnswer:LoadVars = new LoadVars ();
        if (
    != 1)
        {
            
    stop ();
            
    error "Email address not valid";
        }
        else
        {
            
    lv.fname fname.text;
            
    lv.telno telno.text;
            
    lv.comments myInput.comments.text;
            
    lv.from from.text;
            
    lv.sendAndLoad ("mail.php3"lvAnswer"POST");
            
    lvAnswer.onLoad = function ()
            {
                
    gotoAndStop (2);
            };
        }

    You may want to check all the variable names if they are correct in the php script as well as in flash.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Junior Member
    Join Date
    Nov 2005
    Posts
    28
    Ok, that fixed that problem, and I double checked the variable names, but we have made a new problem. Now when I click send, the Name entry field momentarily reads "false" before before going to the thanks for sending message on frame 2 of the main timeline.

    Thanks again for all of your help. It is greatly appreciated!!

  8. #8
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Add another = after if (fname.text =
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Junior Member
    Join Date
    Nov 2005
    Posts
    28

    Talking Working file

    Thank you so much for your help!

    I updated the original file with the correct code and am attaching here for future users. You will have to add your own scroller since I bought mine and as such, cannot distribute.

    Cheers
    Attached Files Attached Files

  10. #10
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    I'm also trying to get this mailer to work and after rereading all of the posts I noticed that loadvars() was stated to have issues with levels. My contact appears on level four of my flash movie. How should I modify Cancerinform's code to get that to work?

    Thanks

  11. #11
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You need to be more specific. What exactly is the problem?
    - The right of the People to create Flash movies shall not be infringed. -

  12. #12
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    Well I fixed the files as needed, so that the variables would be picked up from my movie:
    PHP Code:

    var =0;

    function 
    validate (){
        if (
    it_email.text.length >= 7){
            if (
    it_email.text.indexOf ("@") > 0){
                if ((
    it_email.text.indexOf ("@") + 2) < it_email.text.lastIndexOf (".")){
                    if (
    it_email.text.lastIndexOf (".") < (it_email.text.length 2)){
                        
    1;
                        
    // email is fine
                    
    }
                }
            }
        }
    }
    // checks for empty fields then calls email check function
    function formcheck () {
        
    validate ();        
        
    trace(a);
        if (
    it_name.text == "" || it_email.text == "" || it_zip.text == "" || it_comment.text == "") {
            
    stop();
            
    error "You have left blank fields, please fill in all fields. Thank you!";
        } else {
            
    emailcheck ();
        }
    }
    // email check function calls the fucntion at the top, if its satisfied it loads the php script and sends you to frame 2
    function emailcheck (){
        var 
    lv:LoadVars = new LoadVars();
        var 
    lvAnswer:LoadVars = new LoadVars (); 
        if (
    != 1){
            
    stop ();
            
    error "Email address not valid.";
        } else {
            
    lv.name it_name.text;
            
    lv.email it_email.text;
            
    lv.zip it_zip.text;
            
    lv.comment it_comment.text;
            
    trace (lv.name);
            
    trace (lv.email);
            
    trace (lv.zip);
            
    trace (lv.comment);
            
    lv.sendAndLoad ("mail.php3"lvAnswer"POST"); 
            
    lvAnswer.onLoad = function () { 
                
    gotoAndStop ("Sent"); 
            };
        } 

    This code traces everything as stated.

    Then I fixed up the mailer:
    PHP Code:
    <?php

    $adminaddress 
    "email@gmail.com"
    $sitename "site";

    mail("$adminaddress","Contact Page"
    "A customer at $sitename has commented\n
    Name: 
    $name 
    Email: 
    $email\n
    Zip: 
    $zip
    The visitor commented:
    -----------------------------------------------------------------------------------------
    $comment

    Logged Info :
    -----------------------------------------------------------------------------------------
    Using: 
    $HTTP_USER_AGENT
    Hostname: 
    $ip
    IP address: 
    $REMOTE_ADDR
    Date/Time:  
    $date","FROM:$adminaddress"); 

    ?>
    Nothing happens after this point...however this script is in a .swf that is called to level 4, would that be an issue?

  13. #13
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I have never sent from a different level but try a number traces. If you cannot do traces because of a test on the server add a textfield and test if you get a response within the onLoad function.

    Another possibility is to add "this" to all variables and for lv
    var lv:LoadVars = new LoadVars();
    var lvAnswer:LoadVars = new LoadVars ();
    lv = this.lv;
    lvAnswer = this.lvAnswer;
    - The right of the People to create Flash movies shall not be infringed. -

  14. #14
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    Another possibility is to add "this" to all variables and for lv
    var lv:LoadVars = new LoadVars();
    var lvAnswer:LoadVars = new LoadVars ();
    lv = this.lv;
    lvAnswer = this.lvAnswer;
    That traced as all undefined.

    I'm gonna make a text field and try it that way.

  15. #15
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    I just realized that I do get a responce from the onload() function. I have it gotoAndStop("Sent"). Which it does...so I'm still baffled.

  16. #16
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    may be write
    _level4.gotoAndStop("Sent");
    or
    _level0.gotoAndStop("Sent");
    if it is located on level 0.
    Last edited by cancerinform; 10-24-2006 at 09:01 AM.
    - The right of the People to create Flash movies shall not be infringed. -

  17. #17
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    I'm going to start from square one with a "Hello World" test...

  18. #18
    Junior Member
    Join Date
    Aug 2006
    Posts
    28
    Fixed the problem! It was so much easier than I thought....but it turns out that the server I was using would not allow PHP3.....so I redid it in .ASP.

    Sorry for the trouble and thanks for the help!

  19. #19
    Senior Member
    Join Date
    Feb 2004
    Posts
    494
    I wanted to know how I would add it so a person would see the message it was submitted and then take them back to the home page after 10seconds?

    Thanks
    Last edited by tim_ver; 01-18-2007 at 09:33 PM.

  20. #20
    Junior Member
    Join Date
    May 2007
    Posts
    9
    do you guys have a corresponding php 4 or 5 file for this? orgfree.com only supports php 4 or 5. please help. thanks in advance!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center