8 Replies Latest reply: Mar 3, 2010 2:05 PM by PrintingByDBE RSS

    Problem with Contact Form

    PrintingByDBE Community Member

      Hello i had this problem a while back but i beleve i still hav

      ent gotten the issue resolved...

       

      when going to my contact page and entering your information when u hit enter i get an error code...

       

      Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
          at Error$/throwError()
          at flash.net::URLVariables/decode()
          at flash.net::URLVariables()
          at flash.net::URLLoader/onComplete()

        • 1. Re: Problem with Contact Form
          PrintingByDBE Community Member

          here is the code for the contact page and the email.php file.. i am using AS3   ANY INFO OR HELP WOULD BE AWESOME!!!

           

           

          [email.php]

          __________________________________________________________________________________________ ____________________________

           

          <?php

           

          $emailRecipient = "admin@the5150crew.com";
          $emailHeaders = "From: admin@the5150crew.com\r\nContent-type: text/html\r\n";
          $emailHeaders = "Reply-To: " .$_POST["userEmail"]. "\r\n";
          $emailHeaders = "\r\n";

           

          foreach ($_POST as $key => $value) {
             $$key = stripslashes($value);
          }

           

          $emailBody = "<HTML>
          <BODY>
          <TABLE BORDER='1'>
          <TR>
          <TD align='left' width='780'>Email  : ".$userEmail."</TD>
          </TR>
          <TR>
          <TD align='left' width='780'>Name   : ".$userName."</TD>
          </TR>
          <TR>
          <TD align='left' width='780'>Message: <br><br>".$userMessage."</TD>
          </TR>
          </TABLE>
          </BODY>
          </HTML>";

           

          if(mail($emailRecipient, "admin Form\n\n", $emailBody, $emailHeaders)){
            echo "var1=success";
          } else {
            echo "var1=failure";
          }

           

          ?>

           

          [Flash File - Contact Page - Code]

          __________________________________________________________________________________________ ____________________________

          var urlLdr:URLLoader = new URLLoader();

          urlLdr.dataFormat=URLLoaderDataFormat.VARIABLES;


          var urlReq:URLRequest = new URLRequest("email.php");


          var urlVar:URLVariables=new URLVariables();


          submitBtn.addEventListener(MouseEvent.CLICK,submitF);


          function submitF(e:MouseEvent){


          urlVar.userName = userName.text;


          urlVar.userEmail = userEmail.text;


          urlVar.userMessage = userMessage.text


          urlReq.data=urlVar;
          urlReq.method="POST";


          urlLdr.load(urlReq);

          }

          • 2. Re: Problem with Contact Form
            Ned Murphy CommunityMVP

            Try the following changes:

             

            1) Comment out:

             

            urlLdr.dataFormat=URLLoaderDataFormat.VARIABLES;

             

            I haven't had occasion to need such a line, so let it sit idle for the time being.  If this change and the change below prove successful, uncomment the line and see if it stills passes okay.

             

             

            2) Change the method line to:

             

            urlReq.method = URLRequestMethod.POST;

            • 3. Re: Problem with Contact Form
              PrintingByDBE Community Member

              ok so i made those to changes i took out the urlLdr.dataFormat=URLLoaderDataFormat.VARIABLES;

              and changed the urlReq.method -TO- URLRequestMethod.POST;

               

              and i get no errors.... but when i check my inbox nothing is there?

              then when i leave the urlLdr.dataFormat=URLLoaderDataFormat.VARIABLES;

              i get this error in flash when i test it

               

              Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
                  at Error$/throwError()
                  at flash.net::URLVariables/decode()
                  at flash.net::URLVariables()
                  at flash.net::URLLoader/onComplete()

               

              ??? thanks for the help

              • 4. Re: Problem with Contact Form
                Ned Murphy CommunityMVP

                That error is a good indication that the line commented out does not belong.  If you don't get the error message without it, then the form is likely making its way to the processing file.

                 

                I am not any kind of expert with PHP, so you may need to go thru that file's code to see what might be wrong with it--maybe visit a PHP forum for some help as well.  For what I do know, the first few lines where you assign your headers variable, you should be using ther concatenation "." symbol to append each line. As writen now, each line overwrites what precedes it so all you end up with is "/r/n".

                 

                $emailHeaders = "From: admin@the5150crew.com\r\nContent-type: text/html\r\n";
                $emailHeaders .= "Reply-To: " .$_POST["userEmail"]. "\r\n";
                $emailHeaders .= "\r\n";

                • 5. Re: Problem with Contact Form
                  PrintingByDBE Community Member

                  hmm?

                   

                  ok i will check into a php forum. thanks!

                  but before i go to another forum

                   

                  i should take out the \r\n?

                   

                  $emailHeaders = "From: mailto:admin@the5150crew.com\r\nContent-type: text/html.
                  $emailHeaders .= "Reply-To: " .$_POST["userEmail"].
                  $emailHeaders .=.

                   

                  ????

                  • 6. Re: Problem with Contact Form
                    Ned Murphy CommunityMVP

                    I didn't suggest that, if you think I did.  I just suggested you add the "." as I show in the lines I included so that all of your header text is written to the variable and not just the last "\r\n" as it would the way you have it.

                    • 7. Re: Problem with Contact Form
                      PrintingByDBE Community Member

                      ok thank you sorry i mis understood!

                      thanks for the help!

                      ill give it a shot!

                      • 8. Re: Problem with Contact Form
                        PrintingByDBE Community Member

                        hm i tryied didnt seem to work.. guess i gatta try php forums..?

                         

                        thanks for all your help tho!

                         

                        also someone mentioned it to me that PHPMailer ?

                        heard of it?