1 Reply Latest reply on Sep 22, 2009 6:32 AM by RossRitchey

    Flash to PHP form

    cdc515

      I have recently created a flash website and on the contact page i wanted to put a form that would send the information the put in directly to email. After creating the form and coding the flash code which is below i coded the php file and loaded it to my webserver to see if it worked (the webserver supports php scripts) I am not recieving any emails from the form can any one look over my code and tell me my problem.

      Thank You

       

       

      Here is my flash from:

       

       

      http://www.postimage.org/image.php?v=gx1ONXYA


       

       

      Here is my flash code for my form:

       

       


      function clearField()
      {
          txtField1.text = lblName;
          txtField2.text = lblTelephone;
          txtField3.text = lblEmail;
          txtField4.text = lblMessage;
      } // End of the function

      lblName = "Your Name:";
      lblTelephone = "Telephone:";
      lblEmail = "E-mail Address:";
      lblMessage = "Message:";

      countField = 4;
      clearField();
      var arrayLabel = new Array();
      for (i = 1; i < countField + 1; i++)
      {
          txtField = this["txtField" + i];
          txtField.index = i;
          arrayLabel[i] = this["label" + i];
          txtField.tabIndex = i;
          txtField.onSetFocus = function ()
          {
              if (this.text == arrayLabel[this.index])
              {
                  this.text = "";
              } // end if
          };
          txtField.onKillFocus = function ()
          {
              if (this.text == "")
              {
                  this.text = arrayLabel[this.index];
              } // end if
          };
      } // end of for
      btnClear.onRollOver = function ()
      {
          this.gotoAndPlay("over");
      };
      btnClear.onRollOut = btnClear.onReleaseOutside = function ()
      {
          this.gotoAndPlay("out");
      };
      btnClear.onRelease = function ()
      {
          clearField();
      };
      btnSubmit.onRollOver = function ()
      {
          this.gotoAndPlay("over");
      };
      btnSubmit.onRollOut = btnSubmit.onReleaseOutside = function ()
      {
          this.gotoAndPlay("out");
      };
      btnSubmit.onRelease = function ()
      {
          if (_root.content.pages.page5.contactform.txtField1.text == lblName || _root.content.pages.page5.contactform.txtField2.text == lblTelephone || _root.content.pages.page5.contactform.txtField3.text == lblEmail || _root.content.pages.page5.contactform.txtField4.text == lblMessage)
          {
              gotoAndStop(3);
          }
          else
          {
              _root.content.pages.page5.contactform.loadVariables("email.php", "POST");
              gotoAndStop(2);
          } // end else if
      };
      stop ();

       

       

       

       

       

       

      the php code is this:

       

       

       

       

      <?php

      // Create local PHP variables from the info the user gave in the Flash form
      $senderName   = $_POST['lblName'];
      $senderTelephone = $_POST['lblTelephone'];
      $senderEmail     = $_POST['lblEmail'];
      $senderMessage = $_POST['lblMessage'];

      // Strip slashes on the Local variables
      $senderName   = stripslashes($senderName);
      $senderTelephone= stripslashes($senderTelephone);
      $senderEmail     = stripslashes($senderEmail);
      $senderMessage   = stripslashes($senderMessage);


      //!!!!!!!!!!!!!!!!!!!!!!!!!      this my email     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          $to = "
      xxx@xxx.com";
           // Place sender Email address here
          $from = "$senderEmail ";
      $telephone= "$senderTelephone";
          $subject = "Contact from your website";
          //Begin HTML Email Message
          $message = <<<EOF

       

      <html>
        <body bgcolor="#FFFFFF">
      <b>Name</b> = $senderName<br /><br />
      <b>Telephone</b> = $senderTelephone<br /><br />
      <b>Email</b> = <a href="
      mailto:$senderEmail">$senderEmail</a><br /><br />
      <b>Message</b> = $senderMessage<br />
        </body>
      </html>
      EOF;
         //end of message
          $headers  = "From: $from\r\n";
          $headers .= "Content-type: text/html\r\n";
          $to = "$to";

          mail($to, $subject, $message, $headers);

       

      exit();
      ?>

        • 1. Re: Flash to PHP form
          RossRitchey Level 4

          My guess is that the information isn't getting to the PHP.

           

          To confirm, throw a couple echo's in the PHP script to be sure it is.

           

          I also would convert to a LoadVars object in the Flash:

           

          btnSubmit.onRelease = function ()
          {
              if (_root.content.pages.page5.contactform.txtField1.text == lblName || _root.content.pages.page5.contactform.txtField2.text == lblTelephone || _root.content.pages.page5.contactform.txtField3.text == lblEmail || _root.content.pages.page5.contactform.txtField4.text == lblMessage)
              {
                    gotoAndStop(3);
              }
              else
              {
                    var lv:LoadVars = new LoadVars();
          
                    lv.lblName = _root.content.pages.page5.contactform.txtField1.text;
                    lv.lblTelephone = _root.content.pages.page5.contactform.txtField2.text;
                    lv.lblEmail = _root.content.pages.page5.contactform.txtField3.text;
                    lv.lblMessage = _root.content.pages.page5.contactform.txtField4.text;
          
                    lv.send("email.php", "POST");
          
                    gotoAndStop(2);
              } // end else if
          };