3 Replies Latest reply on Aug 6, 2007 3:54 PM by ntsiii

    Simple PHP mail form not working

    HyderAlamgir Level 1
      I've spent my entire day trying to troubleshoot this. Its ridiculous. There's no reason why it shouldn't work.

      It's a simple feedback page. Please see if I'm missing something something!

      Thanks everyone!



      PHP File path is correct
      PHP File gives no errors
      The LinkBar will eventually filter the click between Send and Reset, right now I was just testing the form.

      You can view the SWF HERE




      quote:

      <mx:HTTPService

      id="contact_info"

      url="php/mailform.php"
      method="POST"

      resultFormat="text"
      result="{Alert.show(event.message.toString())}">

      <mx:request xmlns="">

      <name>{name_input.text}</name>
      <company>{company_input.text}</company>
      <title>{title_input.text}</title>

      <phone1>{phone1code1_input.text+
      phone1code2_input.text+
      phone1no_input.text}</phone1>
      <phone2>{phone2code1_input.text+
      phone2code2_input.text+
      phone2no_input.text}</phone2>

      <city>{city_input.text}</city>
      <state>{state_input.text}</state>
      <country>{country_input.text}</country>

      <comment>{comment_input.text}</comment>

      </mx:request>

      </mx:HTTPService>





      <mx:LinkBar

      id="button_linkbar"

      fontFamily="BoldVerdana"
      fontSize="{baseFontSize}"

      itemClick="contact_info.send()">

      <mx:dataProvider>

      <mx:String>Send</mx:String>
      <mx:String>Reset</mx:String>

      </mx:dataProvider>

      </mx:LinkBar>





      php/mailform.php


      <?php

      $name=$_POST['name'];
      $company=$_POST['company'];
      $title=$_POST['title'];

      $phone1=$_POST['phone1'];
      $phone2=$_POST['phone2'];

      $city=$_POST['city'];
      $state=$_POST['state'];
      $country=$_POST['country'];

      $comment=$_POST['comment'];


      $hdr=$name.'/n/n'.
      $company.'/n'.
      $title.'/n/n'.
      $phone1.'/n'.
      $phone2.'/n/n'.
      $city.'/n'.
      $state.'/n'.
      $country;

      $msg=$comment;

      mail('myemailaddress@censored.com','TEST',$msg,$hdr);

      echo 'Your email has been sent. Thank you!';
      ?>
        • 1. Re: Simple PHP mail form not working
          HyderAlamgir Level 1
          BUMP!

          hlp plz!
          • 2. Re: Simple PHP mail form not working
            BLXWebMaster Level 1
            Although your methods might work, this is typically how I handle posting form info. It allows for a little more flexibility in fromatting etc...

            I tested this and works fine in my environment.

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

            <mx:Script>
            <![CDATA[
            import mx.collections.ArrayCollection;
            import mx.events.FlexEvent
            import mx.controls.*;
            import mx.events.*;

            public function postEmail(StrURL:String):void {
            // Validation Here.
            var indexSelected:int;
            var httpURL:URLRequest = new URLRequest(StrURL);
            var Form:URLVariables = new URLVariables();
            httpURL.method = URLRequestMethod.POST;

            // Form Fields
            Form.name = name_input.text;
            Form.company = company_input.text;
            Form.title = title_input.text;
            Form.phone1 = phone1code1_input.text + phone1code2_input.text + phone1no_input.text;
            Form.phone2 = phone2code1_input.text + phone2code2_input.text + phone2no_input.text;
            Form.city = city_input.text;
            Form.state = state_input.text;
            Form.country = country_input.text;
            Form.comment = comment_input.text;

            httpURL.data = Form;
            navigateToURL(httpURL);
            }

            private function clickHandler():void {
            switch (button_linkbar.selectedIndex) {
            case 0 : //Send
            postEmail(' http://127.0.0.1/test1/mailform.php');
            break;
            case 1 : //Reset
            break;
            default :
            }
            }
            ]]>
            </mx:Script>

            <mx:LinkBar id="button_linkbar" fontFamily="BoldVerdana" itemClick="clickHandler();">
            <mx:dataProvider>
            <mx:String>Send</mx:String>
            <mx:String>Reset</mx:String>
            </mx:dataProvider>
            </mx:LinkBar>
            <mx:Canvas x="10" y="62" width="464" height="294" backgroundColor="#ffffff">
            <mx:TextInput x="102" y="10" id="name_input"/>
            <mx:TextInput x="102" y="40" id="company_input"/>
            <mx:TextInput x="102" y="70" id="title_input"/>
            <mx:TextInput x="102" y="100" width="48" id="phone1code1_input"/>
            <mx:TextInput x="102" y="158" id="city_input"/>
            <mx:TextInput x="102" y="188" id="state_input"/>
            <mx:Label x="10" y="12" text="Name"/>
            <mx:Label x="10" y="42" text="Company"/>
            <mx:Label x="10" y="72" text="Title"/>
            <mx:Label x="10" y="102" text="Phone 1"/>
            <mx:TextInput x="158" y="100" width="48" id="phone1code2_input"/>
            <mx:TextInput x="214" y="100" width="48" id="phone1no_input"/>
            <mx:TextInput x="102" y="128" width="48" id="phone2code1_input"/>
            <mx:Label x="10" y="130" text="Phone 2"/>
            <mx:TextInput x="158" y="128" width="48" id="phone2code2_input"/>
            <mx:TextInput x="214" y="128" width="48" id="phone2no_input"/>
            <mx:TextInput x="102" y="218" id="country_input"/>
            <mx:Label x="10" y="160" text="City"/>
            <mx:Label x="10" y="190" text="State"/>
            <mx:Label x="10" y="220" text="Country"/>
            <mx:TextInput x="102" y="248" id="comment_input"/>
            <mx:Label x="10" y="250" text="Commment"/>
            </mx:Canvas>
            </mx:Application>

            Good Luck
            • 3. Re: Simple PHP mail form not working
              ntsiii Level 3
              Yes, declaritive syntax and binding is often convenient, but it is very hard to debug. I never use it with data service calls, but alwasy create the request object, invoke send, and handler the result in AS functions, where I can see what is happening/ /not.

              Tracy