#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    6
    Rep Power
    0

    Need Help Flash Email-I know this get asked alot


    I hate to be repetitive as I can see this gets asked daily, but I just can't seem to get this script working to send email using php after getting variables from flash.

    I have used two input boxes for message and user email address naming each variable Smessage and Semail respectively. I also have a blank dynamic text box named Output on the following key frame (9).

    Here is the code for the send button in flash:

    on (press) {
    sender_mail = Semail.text;
    sender_message = Smessage.text;
    loadVariables("mail.php", this, "POST");
    theResponse = output;
    gotoAndStop(9);
    }

    Here is the code for the mail.php:

    <?
    if(!empty($_POST['sender_mail'])
    || !empty($_POST['sender_message'])
    {
    $to = "belle@classicbelle.com"; // replace with your mail address
    $s_mail = $_POST['sender_mail'];
    $subject = "Newsletter Add";
    $body = stripslashes($_POST['sender_message']);
    $body .= "\n\n---------------------------\n";
    $header = "From: <$s_mail>\n";
    $header .= "Reply-To: <$s_mail>\n";
    $header .= "X-Mailer: PHP/" . phpversion() . "\n";
    $header .= "X-Priority: 1";

    if(@mail($to, $subject, $body, $header))
    {
    echo "output=Email Sent";
    } else {
    echo "output=error";
    }
    } else {
    echo "output=error";
    }
    ?>

    My problem is that the output box does not show the answer and the email is never sent. I have altered a script I saw to use just two fields, so I may have altered the function somewhat, but I just don't see where I am wrong.

    Thanks so much for any help you can provide.
  2. #2
  3. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Heya, you're actually having two seperate problems. The first is that the output TextField will not show anything as you're trying to load the data into it straight away after calling loadVariables(). Calling loadVariables does not return the data instantly even though it may seem to especially when testing locally. You can either write your own checking method using onEnterFrame or setInterval or you can use the built in LoadVars class which has an event handler called onLoad which only gets called after the data has been returned to Flash. You'd move the bit of code which outputs the result into that function.

    The second problem is to do with the email not getting sent. I'd say the first thing to do is switch over to using LoadVars as I mentioned earlier and then we can start getting some output from your PHP script to see where it's going wrong.
    Quis custodiet ipsos custodes?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    6
    Rep Power
    0

    Not familiar


    I am not that familiar with flash coding. I know most server side.

    I really just need a simple simple one not using outlook to take the email address and message of the user and email it to me.

    I have searched hundreds of threads and tutorials, but some are more complicated than I need, not mention every single one is different, not like in simple html forms.

    Any advice? I will upload my zip of the project to here:

    (URL address blocked: See forum rules)/flash/flash.zip
  6. #4
  7. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    I already told you what I recommend, did you even try it?
    Quis custodiet ipsos custodes?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    6
    Rep Power
    0
    Originally Posted by Tann San
    I already told you what I recommend, did you even try it?
    I would but I don't know how to use loadvars, it doesnt work the same, so I would have to edit the rest of code. And yes I did try it. Sorry for late reply, been on vacation.

    I will try it again, but I am not too familiar with flash, si I doubt I can get it.

    J
  10. #6
  11. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Hi, if you look at the word LoadVars in my second to last post you'll see that it's a link to a google search with hundreds of examples of how to use it.
    Quis custodiet ipsos custodes?
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    6
    Rep Power
    0
    Originally Posted by Tann San
    Hi, if you look at the word LoadVars in my second to last post you'll see that it's a link to a google search with hundreds of examples of how to use it.
    Ok Here is what I have. I have some issues thought that I want to work out. First. This method calls the php page and brings it up, but cant I use it without forcing IE to open it on the users desktop. Second, I cant figure out how to display "Loading" in the dynamic text box while its sending, and a checking method to then display "error" or "success".

    I did find this article, but it is more complicated and uses multiple frames rather than the dynamic text box:
    thegoldenmean.com/technique/flashMX_mailform1.html

    Here is my current code:

    Code:
    function sendForm () {
    	contact = new LoadVars ();
    	contact.email = email.text;
    	contact.comments = comments.text;
    	contact.send ("(URL address blocked: See forum rules)", "POST");
    }
    
    send_btn.onRelease = function () {
    	if (email.text == "" || comments.text == "") {
    		status_txt.text = "Please complete the entire form ...";
    	} else {
    		status_txt.text = "Thank you for your comments!";
    		sendForm ();
    	}
    };
  14. #8
  15. No Profile Picture
    Gotta get to the next screen..
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2003
    Location
    Legion of Dynamic Discord
    Posts
    6,678
    Rep Power
    3165
    Heya, you're most of the way there:
    Code:
    function sendForm ()
       {
          // If you do this then you wont see it read "Thank you for your comments!"
          status_txt.text = "Loading";
    
          contact = new LoadVars ();
          contact.email = email.text;
          contact.comments = comments.text;
    
          // This gets called when the data has been returned to LoadVars
          contact.onLoad = function(success)
             {
                if(success)
                   {
                      status_txt.text = "Loading Successful";
                   }
                else
                   {
                      status_txt.text = "Loading Failed";
                   }
             }
    
          // Needed to change this to sendAndLoad so that the onLoad function gets called
          contact.sendAndLoad ("http://forums.devshed.com", contact, "POST");
       }
    Quis custodiet ipsos custodes?
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    6
    Rep Power
    0
    Wow is all I can say. I spent literally four weeks trying to get this to work. Then in one night I start it, then you finish it up. Just amazing! Thanks a million.

    I think this thread is gonna be a huge help to others; I searched and searched, but rarely does someone show their load vars method that also uses sendandload and of which uses a dynamic text box. Not to mention realizing how the php deals with the incoming variables. Anyways, it works perfect now! Thanks again Tann San!

IMN logo majestic logo threadwatch logo seochat tools logo