Send Mail via php using Flash 8

  • Heart
  • Expert
  • Expert
  • User avatar
  • Joined: Aug 29, 2003
  • Posts: 634
  • Loc: Welcome To, Crazy World!
  • Status: Offline

Post December 4th, 2007, 11:47 am

Hey guys! I have a problem for you guys. I have done a send mail via php using variables in flash but currently I am having some problems getting it to send for me on a different site that I am currently working on. It's not sending at all for me. I don't even get an blank email or anything else sent. I don't know if it's because I am using Flash 8 now or what the problem is. I am hoping it's a small error or something that I am over looking and maybe one of you can see what I can not.


Script for my send button:
Code: [ Download ] [ Select ]
on (release) {
    info.loadVariables("vmail.php", "POST");
    
    info.txt1 = "Name:";
    info.txt2 = "E-Mail:";
    info.txt3 = "Phone:";
    info.txt6 = "Message:";
    
    this.gotoAndStop(2);
}
  1. on (release) {
  2.     info.loadVariables("vmail.php", "POST");
  3.     
  4.     info.txt1 = "Name:";
  5.     info.txt2 = "E-Mail:";
  6.     info.txt3 = "Phone:";
  7.     info.txt6 = "Message:";
  8.     
  9.     this.gotoAndStop(2);
  10. }


My php script:
Code: [ Download ] [ Select ]
<?php
$sendTo = "mail@mail.com";
$subject = "SITE CONTACT";
$headers = "From: " . $_POST["txt1"];
$headers .= "Reply-To: " . $_POST["txt2"];
$headers .= "Return-path: " . $_POST["txt2"];
$message = $_POST["txt1"] . $_POST["txt2"] . $_POST["txt3"] . $_POST["txt6"];
mail($sendTo, $subject, $message, $headers);
?>
  1. <?php
  2. $sendTo = "mail@mail.com";
  3. $subject = "SITE CONTACT";
  4. $headers = "From: " . $_POST["txt1"];
  5. $headers .= "Reply-To: " . $_POST["txt2"];
  6. $headers .= "Return-path: " . $_POST["txt2"];
  7. $message = $_POST["txt1"] . $_POST["txt2"] . $_POST["txt3"] . $_POST["txt6"];
  8. mail($sendTo, $subject, $message, $headers);
  9. ?>


txt1 = name
txt2 = email
txt3 = phone
txt6 = message

You should know that "info" is a movieclip that I am storing my variables (txt1-6). And I am sure that I have all of them labeled for instance and var:.

here is a screen shot of it in case you are wondering why things are the way that they are:
Image

Any solutions or suggestions please let me know! Thank you for our help!
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post December 4th, 2007, 11:47 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 22501
  • Loc: Pittsburgh PA
  • Status: Offline

Post December 4th, 2007, 1:44 pm

Not certain why you need the "info". Also you aren't allowing for empty required fields which means you could get a lot of emails with missing or no information. Really you would want something in all those fields so I'd set it up something like this. (of course you'd have to supply an "error" message and a "sent" message using the appropriate labels to go to that part of the timeline. This is essentially how mine are set up.

For your action:

Code: [ Download ] [ Select ]
//note - I would replace your txt1, txt2,txt3 and txt6 labels with name, phone, email and message respectively

on (release) {
    if (name eq "" or phone eq "" or email eq "" or message eq "") {
        error.gotoAndPlay("error");
    } else {
        loadVariablesNum("vmail.php", 0, "POST");
        error.gotoAndPlay("sent");
        name = "";
        phone = "";
        email = "";
        message = "";
    }
}
  1. //note - I would replace your txt1, txt2,txt3 and txt6 labels with name, phone, email and message respectively
  2. on (release) {
  3.     if (name eq "" or phone eq "" or email eq "" or message eq "") {
  4.         error.gotoAndPlay("error");
  5.     } else {
  6.         loadVariablesNum("vmail.php", 0, "POST");
  7.         error.gotoAndPlay("sent");
  8.         name = "";
  9.         phone = "";
  10.         email = "";
  11.         message = "";
  12.     }
  13. }



then for vmail.php I would have the following (I assume mail@mail.com is bogus and you would have a real one there)

PHP Code: [ Download ] [ Select ]
<?
 
    if (isset($HTTP_POST_VARS)) {
 
           
 
            $name = $HTTP_POST_VARS["name"];
 
            $phone = $HTTP_POST_VARS["phone"];
 
            $email = $HTTP_POST_VARS["email"];
 
            $message = $HTTP_POST_VARS["message"];
 
            }
 
 
 
   $to = "mail@mail.com";
 
   $subject = "SITE CONTACT";
 
   $msg .= "Senders Name: " ."$name\n\n";
 
   $msg .= "Phone: " ."$phone\n\n";
 
   $msg .= "Email: " ."$email\n\n";
 
   $msg .= "Message: " ."$message\n\n";
 
    $msg .= "This message was sent to you from My Site Contact  Form.\n\n";
 
    $msg .= "Do not reply to this email directly.";
 
 
 
  mail($to, $subject, $msg, "From: My Site Contact Form\nReply-To: $email\n");
 
 
 
?>
  1. <?
  2.  
  3.     if (isset($HTTP_POST_VARS)) {
  4.  
  5.            
  6.  
  7.             $name = $HTTP_POST_VARS["name"];
  8.  
  9.             $phone = $HTTP_POST_VARS["phone"];
  10.  
  11.             $email = $HTTP_POST_VARS["email"];
  12.  
  13.             $message = $HTTP_POST_VARS["message"];
  14.  
  15.             }
  16.  
  17.  
  18.  
  19.    $to = "mail@mail.com";
  20.  
  21.    $subject = "SITE CONTACT";
  22.  
  23.    $msg .= "Senders Name: " ."$name\n\n";
  24.  
  25.    $msg .= "Phone: " ."$phone\n\n";
  26.  
  27.    $msg .= "Email: " ."$email\n\n";
  28.  
  29.    $msg .= "Message: " ."$message\n\n";
  30.  
  31.     $msg .= "This message was sent to you from My Site Contact  Form.\n\n";
  32.  
  33.     $msg .= "Do not reply to this email directly.";
  34.  
  35.  
  36.  
  37.   mail($to, $subject, $msg, "From: My Site Contact Form\nReply-To: $email\n");
  38.  
  39.  
  40.  
  41. ?>


Been using that for a couple years and works fine.

//lol - Took me awhile, but I just realized this is you! How ya been old friend?
"The web is a dominatrix. Every where I turn, I see little buttons ordering me to Submit."
Play sports pools and discuss sports topics at Boasting Rights Sports Forum
Get paid to write articles - www.associatedcontent.com
  • JesterPrime
  • Born
  • Born
  • No Avatar
  • Joined: Jan 20, 2008
  • Posts: 2
  • Status: Offline

Post January 20th, 2008, 8:30 am

Hi I know this is a very old topic but im tryin to get this code to send an auto reply to the sender. Im pretty sure the code is the last bit of this line,

mail($to, $subject, $msg, "From: My Site Contact Form\nReply-To: $email\n");

Some how I got it to work once but nothing since. Please Help
  • petra825
  • Born
  • Born
  • No Avatar
  • Joined: Mar 09, 2008
  • Posts: 1
  • Status: Offline

Post March 9th, 2008, 5:32 pm

Hi,

Thank you so much, this is the first technique that has worked for me so far with Flash 8. I am having one issue, the email that get from the form comes out really weird, it looks like this:

Senders Name: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">petra vincent</FONT></P></TEXTFORMAT>

subject: SITE CONTACT

Email: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">info@petra825.com</FONT></P></TEXTFORMAT>

org: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">my organization</FONT></P></TEXTFORMAT>

Comment: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\"></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"13\" COLOR=\"#000000\" LETTERSPACING=\"0\" KERNING=\"0\">this is my comment this is my comment, please work please</FONT></P></TEXTFORMAT>

This message was sent to you from My Site Contact Form.

Do not reply to this email directly.

is there anyway to fix this. Thank you so much in advance.

Best,
Petra
  • JesterPrime
  • Born
  • Born
  • No Avatar
  • Joined: Jan 20, 2008
  • Posts: 2
  • Status: Offline

Post March 9th, 2008, 5:44 pm

Hi petra825, since my post I've learnt a lot about how this form works. Not sure why its doing that but if you want to post your AS & php code I'll have a look. JesterP
  • tbenfield
  • Born
  • Born
  • No Avatar
  • Joined: May 22, 2008
  • Posts: 2
  • Status: Offline

Post May 22nd, 2008, 8:47 am

Hello guys, well I have got this email posting working from a flash site with the php using the code posted by ANTO/TW above but as with preta825 above I am getting some weird coding in the email content:
__________________________________________________________________

Senders Name: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\">tony</FONT></P></TEXTFORMAT>

Surname: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\"></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\">benfield</FONT></P></TEXTFORMAT>

Company: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\"></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\">nostalgia bank</FONT></P></TEXTFORMAT>

Email: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\">slaes@nostalgiabank</FONT></P></TEXTFORMAT>

Message: <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"verdana\" SIZE=\"10\" COLOR=\"#626C77\" LETTERSPACING=\"0\" KERNING=\"0\">does this work?</FONT></P></TEXTFORMAT>

Subject:

SITE CONTACT This message was sent to you from My Site Contact Form. Do not reply to this email directly.

__________________________________________________________________

Any advice would really help guys.

Tony
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 22501
  • Loc: Pittsburgh PA
  • Status: Offline

Post May 22nd, 2008, 9:06 am

It looks like in your Flash Form you have Render Text as HTML enabled. Check each of your textInput fields and make sure that is disabled. It's the button that looks like <> just to the right of Single Line in the Properties Inspector.
"The web is a dominatrix. Every where I turn, I see little buttons ordering me to Submit."
Play sports pools and discuss sports topics at Boasting Rights Sports Forum
Get paid to write articles - www.associatedcontent.com
  • tbenfield
  • Born
  • Born
  • No Avatar
  • Joined: May 22, 2008
  • Posts: 2
  • Status: Offline

Post May 27th, 2008, 4:02 pm

Thanks bud, that resolved the issue.
  • bozboz
  • Novice
  • Novice
  • No Avatar
  • Joined: Mar 13, 2007
  • Posts: 31
  • Loc: Brighton
  • Status: Offline

Post June 7th, 2008, 12:21 pm

Yeah that one confused me for months as well

If your lazy you can use the striptags() function in php as well, do this on the message before its sent. Especially if you cant be bothered to go back and recompile the swf
  • codzprc
  • Born
  • Born
  • No Avatar
  • Joined: Jun 21, 2008
  • Posts: 2
  • Status: Offline

Post June 21st, 2008, 8:59 pm

All of this has been incredibly helpful to me so far - but I have a twist I'd like to add. I'm using this code to send a password to me, as well as the ip address (well, just the password so far) The problem seems to be in my php code - since the Flash shouldn't have anything to do with the IP bit-- right? anyway. Nothing I try is working to relay the IP address through a message... Thank you in advance for help.

my flash code is (explanations below):


Code: [ Download ] [ Select ]
var myPassword:String = 'apples';
var jungle = password_txt.text
 
 
onEnterFrame = function  () {
jungle = password_txt.text
    }
 
submit_mc.onRelease = function (){
       
   loadVariablesNum("vmail.php", 0, "POST");
   jungle = "";
     
 
   if (password_txt.text == myPassword) {
     gotoAndStop("vidz");
   } else {
     gotoAndStop("invalid");
}
}
  1. var myPassword:String = 'apples';
  2. var jungle = password_txt.text
  3.  
  4.  
  5. onEnterFrame = function  () {
  6. jungle = password_txt.text
  7.     }
  8.  
  9. submit_mc.onRelease = function (){
  10.        
  11.    loadVariablesNum("vmail.php", 0, "POST");
  12.    jungle = "";
  13.      
  14.  
  15.    if (password_txt.text == myPassword) {
  16.      gotoAndStop("vidz");
  17.    } else {
  18.      gotoAndStop("invalid");
  19. }
  20. }



PHP code:


Code: [ Download ] [ Select ]
php<?
if (isset($HTTP_POST_VARS)) {
 
$name = $HTTP_POST_VARS["jungle"];
$ip  = $_SERVER['REMOTE_ADDR'];
}
 
$to = "Jim@bob.xom";
$subject = "SITE CONTACT";
$msg .= "Senders Name: " ."$name\n\n";
$msg .= "This message was sent to you from My Site Contact Form.\n\n";
$msg .= "Do not reply to this email directly.";
 
mail($to, $subject, $name, $msg, $ip );
 
?>/php
  1. php<?
  2. if (isset($HTTP_POST_VARS)) {
  3.  
  4. $name = $HTTP_POST_VARS["jungle"];
  5. $ip  = $_SERVER['REMOTE_ADDR'];
  6. }
  7.  
  8. $to = "Jim@bob.xom";
  9. $subject = "SITE CONTACT";
  10. $msg .= "Senders Name: " ."$name\n\n";
  11. $msg .= "This message was sent to you from My Site Contact Form.\n\n";
  12. $msg .= "Do not reply to this email directly.";
  13.  
  14. mail($to, $subject, $name, $msg, $ip );
  15.  
  16. ?>/php








flash explanation (for those that are wondering about the vars):::

Code: [ Download ] [ Select ]
 
    //set password
var myPassword:String = 'apples';
    //sets password to transfer to a dynamic text field for php reasons
var jungle = password_txt.text
 
   // live updates dynamic field so when they submit the code goes to php
onEnterFrame = function  () {
jungle = password_txt.text
    }
 
submit_mc.onRelease = function (){
       
   loadVariablesNum("vmail.php", 0, "POST");
   jungle = "";
     
 
   if (password_txt.text == myPassword) {
     gotoAndStop("vidz");
   } else {
     gotoAndStop("invalid");
}
}
  1.  
  2.     //set password
  3. var myPassword:String = 'apples';
  4.     //sets password to transfer to a dynamic text field for php reasons
  5. var jungle = password_txt.text
  6.  
  7.    // live updates dynamic field so when they submit the code goes to php
  8. onEnterFrame = function  () {
  9. jungle = password_txt.text
  10.     }
  11.  
  12. submit_mc.onRelease = function (){
  13.        
  14.    loadVariablesNum("vmail.php", 0, "POST");
  15.    jungle = "";
  16.      
  17.  
  18.    if (password_txt.text == myPassword) {
  19.      gotoAndStop("vidz");
  20.    } else {
  21.      gotoAndStop("invalid");
  22. }
  23. }
  • bozboz
  • Novice
  • Novice
  • No Avatar
  • Joined: Mar 13, 2007
  • Posts: 31
  • Loc: Brighton
  • Status: Offline

Post June 22nd, 2008, 3:30 am

try

php<?
if (isset($HTTP_POST_VARS)) {

$name = $HTTP_POST_VARS["jungle"];
$ip = $_SERVER['REMOTE_ADDR'];
}

$to = "youremail@yoursite.com";
$subject = "SITE CONTACT";
$msg .= "Senders Name: " ."$name\n\n";
$msg .= "This message was sent to you from My Site ContactForm.\n\n IP address was $ip ";
$msg .= "Do not reply to this email directly.";

mail($to, $subject, $name, $msg);

?>/php
  • codzprc
  • Born
  • Born
  • No Avatar
  • Joined: Jun 21, 2008
  • Posts: 2
  • Status: Offline

Post June 22nd, 2008, 3:47 pm

Awesome! That worked perfectly, thanks. So basically it didn't print because it wasn't in quotes?? I'm not very php savvy, as you can tell.

thanks again
  • magic1000
  • Born
  • Born
  • No Avatar
  • Joined: Jun 25, 2008
  • Posts: 3
  • Status: Offline

Post June 25th, 2008, 5:07 am

Thank all!
  • contutti
  • Born
  • Born
  • No Avatar
  • Joined: Jul 03, 2008
  • Posts: 2
  • Status: Offline

Post July 3rd, 2008, 8:43 am

Hi to all. I seem to have the same problem, but I cannot solve it.
I have a form in flash.

The code on "Send" button is (simplified):

on (press) {
loadVariablesNum("mail.php", 0, "POST")
}


My PHP is:
<?php
$sendTo = "(my mail is here)";
$subject = "Message from My page";
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = $_POST["message"];
mail($sendTo, $subject, $message, $headers);
?>


And when I recieve the mail, it goes
<TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial Narrow\" SIZE=\"14\" COLOR=\"#666666\" LETTERSPACING=\"0\" KERNING=\"0\">Testing message</FONT></P></TEXTFORMAT>
And the same in the "Respond to" field.

I tried:
- Enabling the <> button.
- Disabling the <> button.
- Set A/V to 0
- Changing fonts

Nothing worked... HALP!
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 22501
  • Loc: Pittsburgh PA
  • Status: Offline

Post July 3rd, 2008, 8:57 am

Make sure you've disable the <> button on all fields.

After you've made your changes and published your file, before you test it on your website, make sure you've cleared your brower's cache/temporary internet files. Most likely you are loading a cached version of the swf that didn't work right.
"The web is a dominatrix. Every where I turn, I see little buttons ordering me to Submit."
Play sports pools and discuss sports topics at Boasting Rights Sports Forum
Get paid to write articles - www.associatedcontent.com
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 3rd, 2008, 8:57 am

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 98 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.