Another PHP/FLASH DILEMA CONTACT FORM sends blank emails

  • e.s.guardian
  • Newbie
  • Newbie
  • e.s.guardian
  • Posts: 8

Post 3+ Months Ago

I have a contact form in my flash site. In short there are two buttons send and clear, when you click on the send button, its supposed to take you to frame label "correct" but nothing happens...meanwhile my inbox is filling up with blank emails. So whats happening? the PHP form isnt gathering my variables?

this is what I have in my Flash form and Php form
Code: [ Select ]
this.stop();
// -------------------<send form LoadVars>------------------- \\
var gatherForm:LoadVars = new LoadVars();
var receiveForm:LoadVars = new LoadVars();
receiveForm.onLoad = function() {
    if (this.response == "passed") {
        name_txt.text = "";
        email_txt.text = "";
        phone_txt.text = "";
        msg_txt.text = "";
        trace("email sent");
        gotoAndStop("correct");
    }
};
function sendForm() {
    gatherForm.email_to = "eric.shomer@gmail.com";
    gatherForm.visitor_comments = msg_txt.text;
    gatherForm.visitor_name = name_txt.text;
    gatherForm.visitor_email = email_txt.text;
    gatherForm.visitor_phone = phone_txt.text;
    // You may want to try the absolute http to this file i.e. http://www.mydomain.com/form.php 
    // If you are testing on the local system and it doesn't know how to parse php,
    // you'll never get a response back from the file.
    gatherForm.sendAndLoad("http://www.bodyshopfitnesscenter.com/email.php", receiveForm, "POST");
}
// -------------------</send form LoadVars>------------------- \\
//--------------------<submit button AS>---------------------\\
// onRelease
submitBtn.onRelease = function() {
    if (email_txt.text == "" || phone_txt.text == "" || name_txt.text == "" || msg_txt.text == "") {
        gotoAndStop("error");
    } else {
        sendForm();
    }
};
//--------------------</submit button AS>---------------------\\

<?php
/***************************************************\
* PHP 4.1.0+ version of email script. For more
* information on the mail() function for PHP, see
* http://www.php.net/manual/en/function.mail.php
\***************************************************/


// First, set up some variables to serve you in
// getting an email. This includes the email this is
// sent to (yours) and what the subject of this email
// should be. It's a good idea to choose your own
// subject instead of allowing the user to. This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.

$sendTo = "eric.shomer@gmail.com";
$subject = "Web Site Reply";

// variables are sent to this PHP page through
// the POST method. $_POST is a global associative array
// of variables passed through this method. From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.


// header information not including sendTo and Subject
// these all go in one variable. First, include From:
$headers = "From: " . $_POST["name"] ." ". $_POST["email"] . "<" . $_POST["phone"] .">\r\n";
// next include a replyto
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
// often email servers won't allow emails to be sent to
// domains other than their own. The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path: " . $_POST["email"];

// now we can add the content of the message to a body variable
$message = $_POST["message"];


// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);

?>
  1. this.stop();
  2. // -------------------<send form LoadVars>------------------- \\
  3. var gatherForm:LoadVars = new LoadVars();
  4. var receiveForm:LoadVars = new LoadVars();
  5. receiveForm.onLoad = function() {
  6.     if (this.response == "passed") {
  7.         name_txt.text = "";
  8.         email_txt.text = "";
  9.         phone_txt.text = "";
  10.         msg_txt.text = "";
  11.         trace("email sent");
  12.         gotoAndStop("correct");
  13.     }
  14. };
  15. function sendForm() {
  16.     gatherForm.email_to = "eric.shomer@gmail.com";
  17.     gatherForm.visitor_comments = msg_txt.text;
  18.     gatherForm.visitor_name = name_txt.text;
  19.     gatherForm.visitor_email = email_txt.text;
  20.     gatherForm.visitor_phone = phone_txt.text;
  21.     // You may want to try the absolute http to this file i.e. http://www.mydomain.com/form.php 
  22.     // If you are testing on the local system and it doesn't know how to parse php,
  23.     // you'll never get a response back from the file.
  24.     gatherForm.sendAndLoad("http://www.bodyshopfitnesscenter.com/email.php", receiveForm, "POST");
  25. }
  26. // -------------------</send form LoadVars>------------------- \\
  27. //--------------------<submit button AS>---------------------\\
  28. // onRelease
  29. submitBtn.onRelease = function() {
  30.     if (email_txt.text == "" || phone_txt.text == "" || name_txt.text == "" || msg_txt.text == "") {
  31.         gotoAndStop("error");
  32.     } else {
  33.         sendForm();
  34.     }
  35. };
  36. //--------------------</submit button AS>---------------------\\
  37. <?php
  38. /***************************************************\
  39. * PHP 4.1.0+ version of email script. For more
  40. * information on the mail() function for PHP, see
  41. * http://www.php.net/manual/en/function.mail.php
  42. \***************************************************/
  43. // First, set up some variables to serve you in
  44. // getting an email. This includes the email this is
  45. // sent to (yours) and what the subject of this email
  46. // should be. It's a good idea to choose your own
  47. // subject instead of allowing the user to. This will
  48. // help prevent spam filters from snatching this email
  49. // out from under your nose when something unusual is put.
  50. $sendTo = "eric.shomer@gmail.com";
  51. $subject = "Web Site Reply";
  52. // variables are sent to this PHP page through
  53. // the POST method. $_POST is a global associative array
  54. // of variables passed through this method. From that, we
  55. // can get the values sent to this page from Flash and
  56. // assign them to appropriate variables which can be used
  57. // in the PHP mail() function.
  58. // header information not including sendTo and Subject
  59. // these all go in one variable. First, include From:
  60. $headers = "From: " . $_POST["name"] ." ". $_POST["email"] . "<" . $_POST["phone"] .">\r\n";
  61. // next include a replyto
  62. $headers .= "Reply-To: " . $_POST["email"] . "\r\n";
  63. // often email servers won't allow emails to be sent to
  64. // domains other than their own. The return path here will
  65. // often lift that restriction so, for instance, you could send
  66. // email to a hotmail account. (hosting provider settings may vary)
  67. // technically bounced email is supposed to go to the return-path email
  68. $headers .= "Return-path: " . $_POST["email"];
  69. // now we can add the content of the message to a body variable
  70. $message = $_POST["message"];
  71. // once the variables have been defined, they can be included
  72. // in the mail function call which will send you an email
  73. mail($sendTo, $subject, $message, $headers);
  74. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • e.s.guardian
  • Newbie
  • Newbie
  • e.s.guardian
  • Posts: 8

Post 3+ Months Ago

any takers?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

1. u wrote:
gatherForm.sendAndLoad("http://www.bodyshopfitnesscenter.com/email.ph p", receiveForm, "POST"); -> there's a space between "email.ph" and "p".
If you copy paste the code from your flash file, then better remove the space.
2. is http://www.bodyshopfitnesscenter.com/email.php actually sending emails? try it with a simple html form with action="http://www.bodyshopfitnesscenter.com/email.php"
which has 3 input texts named : name, email, phone ... and a submit button.
3. You are sending to php:
Code: [ Select ]
  gatherForm.email_to = "eric.shomer@gmail.com";
  gatherForm.visitor_comments = msg_txt.text;
  gatherForm.visitor_name = name_txt.text;
  gatherForm.visitor_email = email_txt.text;
  gatherForm.visitor_phone = phone_txt.text;
  1.   gatherForm.email_to = "eric.shomer@gmail.com";
  2.   gatherForm.visitor_comments = msg_txt.text;
  3.   gatherForm.visitor_name = name_txt.text;
  4.   gatherForm.visitor_email = email_txt.text;
  5.   gatherForm.visitor_phone = phone_txt.text;

but the php code expect only name, email and phone - > see $_POST["name"], $_POST["email"], $_POST["phone"]
so either you change the php files to get the correct posted variables name, or you change the flash file
4. if the php and swf files are not in the same domain, there might be chanches the email will not be send, since the smtp server may be restricted to the same domain. If they are in the same domain, then better use relative path instead of the absolute path: "http://www.bodyshopfitnesscenter.com/email.php"
5. if you want to display the success/fail of the send message, then you'll have to actually send something back to flash, using:
echo "response=passed"; // -> if success
or
echo "response=failed"; // -> if fail
  • billlly
  • Born
  • Born
  • billlly
  • Posts: 1

Post 3+ Months Ago

Eeeks what a pickle nice replies but I think our friend is having some trouble with the basics. Nice strings of fancy code are cool but your just sending e mail right 3 lines of script are all you need then you wont get tied in nots when something wont work have a look at this free flash e mail form with PHP you can see its not so hard to send e mails with flash and PHP : ]
Source is free.

Have a look at the code in the source file not much there but it works every time. : ]

down load
http://electronwebdesign.com/e.mail.form.zip


site
http://www.electronwebdesign.com/
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

It's a two year old post Billy. I assume they've resolved it by now.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 8 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.