3 Replies Latest reply on Aug 31, 2009 7:40 PM by Marlene

    Flex form and PHP code

    Marlene Level 1

       

      I am trying to use the code from A flex Cookbook discussion called "Submitting a Flex form using PHP" The goal is to create a form in Flex and when submitted, have the form data emailed to myself. I have unfortunately spent the entire day on this so ANY HELP WOULD BE APPRECIATED. The original cookbook code is located at

      http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=8523 The code (I enabled source view is at http://www.alexisjean.com/testMail.html. I get an error and never get the email. I have attached the source files in a zip and alse pasting in the code

       

       

       

      THE MXML CODE

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" viewSourceURL="srcview/index.html">

      <mx:Script>

      <![CDATA[

      import mx.controls.Alert;

        private function sendInfo():void{

         if(user.text=="" || email.text=="" || message.text==""){

          mx.controls.Alert.show("Sorry, information appears to be missing!")

          } else {

            svc.send()

          }

        }

        private function thanks(evt:Event):void{

          if (String(svc.lastResult)=="ok") mx.controls.Alert.show("Thanks! Your message has been sent.")

          else mx.controls.Alert.show("Sorry, there was a server error!")

        }

      ]]>

      </mx:Script>

       

      <mx:HTTPService id="svc" url="mail.php" method="POST" contentType="application/x-www-form-urlencoded" resultFormat="text" result="thanks(event)">

               <mx:request>

                    <user>{user.text}</user>

                     <email>{email.text}</email>

                    <message>{message.text}</message>

                   </mx:request>

       

      </mx:HTTPService>

      <mx:Form>   

      <mx:FormItem label="Name"> <mx:TextInput id="user"/> </mx:FormItem>   

      <mx:FormItem label="Email"> <mx:TextInput id="email"/> </mx:FormItem>   

      <mx:FormItem label="Message"> <mx:TextArea width="211" height="117" id="message" /> </mx:FormItem>         

      <mx:FormItem> <mx:Button label="Submit" click="sendInfo()"/></mx:FormItem> 

      </mx:Form>

      </mx:Application>

       

       

       

       

      THE PHP CODE

       

      <?php

      ini_set("SMTP","mail.alexisjean.com");

      ini_set("smtp_port","25");

      ini_set("sendmail_from", "testing@alexisjean.com");

       

       

      $email = $_POST['email'];

      $to = "testing@alexisjean.com";

      $from = "$email";

      $subject = "subject line tester";

      $msg ="Name: ".$_POST['user']."\nEmail: ".$_POST['email']."\nMessage: ".$_POST['message'])) echo "ok";

      else echo "error";