2 Replies Latest reply on Feb 1, 2007 8:11 AM by finalcutexpress

    Flash and PHP

      I downloaded a Flash file with accompanying php file from the exchange. The actionscript and php seem pretty straightforward, but I cannot get it to work. It consists of an HTML page that embeds the .swf and the .php file called to action from within the .swf. The .swf is an interface that allows someone to send an email via .php.

      The actionscript in my Flash file is as follows:

      System.useCodepage = true;
      send_btn.onRelease = function() {
      my_vars = new LoadVars();
      my_vars.sender = email_box.text;
      my_vars.subject = subject_box.text;
      my_vars.message = message_box.text;
      if (my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") {
      my_vars.sendAndLoad("mailer.php", my_vars, "POST");
      } else {
      my_vars.onLoad = function() {
      email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
      if (error_clip._currentframe != 1) {

      The mailer.php file is:


      // read the variables form the string, (this is not needed with some servers).
      $subject = $_REQUEST["subject"];
      $message = $_REQUEST["message"];
      $sender = $_REQUEST["sender"];

      $full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;
      $message= $full_message;

      /$message = stripslashes($message);
      $subject = stripslashes($subject);
      $sender = stripslashes($sender);

      $subject = "Contact form ". $subject;

      if(isset($message) and isset($subject) and isset($sender)){
      mail("blahblah@blahblah.net", $subject, $message, "From: $sender");
      // the blahblah@ has been replaced with my real email address on the file residing on my server
      // I changed it here for privacy reasons

      At present, I have all files residing in the root folder.

      Any suggestions as to why this isn't working -- something on my php.ini file perhaps?

      Thanks in advance for any/all suggestions.
        • 1. Re: Flash and PHP
          Level 7
          Couple things that I notice. First, I never like using only one LoadVars
          object for both sending and receiving, it just never seems to work properly.
          Instead, I do:

          var receiver:LoadVars = new LoadVars();
          var sender:LoadVars = new LoadVars();

          receiver.onLoad = function(success:Boolean){

          sender.from = email_box.text;
          sender.subject = subject_box.text;

          sender.sendAndLoad("full_url_to_php_script - not just mailer.php",

          Note that you need the full URL to your mailer.php script, and you don't
          need to specify Post, it's the default.

          In your PHP you should change the $_REQUEST's to $_POST's once you're done
          with testing. Otherwise, the parameters can be passed in the URL itself and
          your mailer can be used by anyone.

          Dave -
          Head Developer
          Adobe Community Expert

          • 2. Re: Flash and PHP
            finalcutexpress Level 1
            Hi Dave -

            Thanks very much for the suggestion(s). I'll give it a try.