3 Replies Latest reply on Sep 6, 2007 5:47 PM by J_Fraser

    FLEX and PHP

    George Donn
      Hello,

      This project tested on flexbuilder ( locally ) works great! The flex app. sends variables to PHP and PHP takes those variables and saves them to a text file on the server.

      PROBLEM:
      I went to run this application on my web site....I fill in the form, click submit, and I go to check for the new txt file on my server. The text file is created but the variables are not stored in it.


      Some help.....
        • 1. Re: FLEX and PHP
          batmitra Level 1
          hi
          can we see some code?
          • 2. Re: FLEX and PHP
            George Donn Level 1
            More details..... The sever I am running is a unix apache. Is the environment differant?

            MXML CODE: Here is my http service

            <mx:HTTPService id="userRequest" url=" http://localhost/TestApp/request.php" useProxy="false" method="POST">
            <mx:request xmlns="">
            <nameIn>{nameIn.text}</nameIn>
            <emailIn>{emailIn.text}</emailIn>
            <addIn>{addIn.text}</addIn>
            <compIn>{compIn.text}</compIn>
            <csIn>{csIn.text}</csIn>
            <zipIn>{zipIn}</zipIn>
            <phoneIn>{phoneIn.text}</phoneIn>
            <q1>{q1.text}</q1>

            // I HAVE 14 more question but I wont add them on.


            </mx:request>
            </mx:HTTPService>



            PHP CODE:

            <?php




            //Create PHP variables getting info from the flex form
            $strName = $_POST["nameIn"];
            $strAddress = $_POST["addIn"];
            $strEmail = $_POST["emailIn"];
            $strCompany = $_POST["compIn"];
            $strCity = $_POST["csIn"];
            $strPhone = $_POST["phoneIn"];
            $strQ1 = $_POST["q1"];
            $strQ2 = $_POST["q2"];
            $strQ3 = $_POST["q3"];
            $strQ4 = $_POST["q4"];
            $strQ5 = $_POST["q5"];
            $strQ6 = $_POST["q6"];
            $strQ7 = $_POST["q7"];
            $strQ8 = $_POST["q8"];
            $strQ9 = $_POST["q9"];
            $strQ10 = $_POST["q10"];
            $strQ11 = $_POST["q11"];
            $strQ12 = $_POST["q12"];
            $strQ13 = $_POST["q13"];
            $strQ14 = $_POST["q14"];
            $strQ15 = $_POST["q15"];




            //Building the content for the text file
            $strContent = "NAME: " . $strName . "\r\n" .
            "ADDRESS: " . $strAddress . "\r\n" .
            "Email: " . $strEmail . "\r\n" .
            "Company: " . $strCompany . "\r\n" .
            "City: " . $strCity . "\r\n" .
            "Phone: " . $strPhone . "\r\n" .
            "Q1: " . $strQ1 . "\r\n" .
            "Q2: " . $strQ2 . "\r\n" .
            "Q3: " . $strQ3 . "\r\n" .
            "Q4: " . $strQ4 . "\r\n" .
            "Q5: " . $strQ5 . "\r\n" .
            "Q6: " . $strQ6 . "\r\n" .
            "Q7: " . $strQ7 . "\r\n" .
            "Q8: " . $strQ8 . "\r\n" .
            "Q9: " . $strQ9 . "\r\n" .
            "Q10: " . $strQ10 . "\r\n" .
            "Q11: " . $strQ11 . "\r\n" .
            "Q12: " . $strQ12 . "\r\n" .
            "Q13: " . $strQ13 . "\r\n" .
            "Q14: " . $strQ14 . "\r\n" .
            "Q15: " . $strQ15 . "\r\n" ;








            WriteToLog($strName, $strContent);

            //add the user
            //$sSql = "INSERT INTO TblQuest(nameIn, addIn, emailIn) VALUES ('" . $strName . "', '" . $strAddress .

            "', '" . $strEmail . "')";
            //$Result = mysql_query($sSql);

            //mysql_close();

            function WriteToLog($theUser, $theContent)
            {
            $ourFileName = "" . $theUser . "_" . date('mdY') . "_" . date("H_i_s") . ".txt";

            //echo "FILENAME: " . $ourFileName;
            $ip_address = getenv('REMOTE_ADDR');
            //$last_page_url = getenv('REQUEST_URI');

            $fh = fopen($ourFileName, 'a') or die("can't open file");

            $stringData = "CONTENT:\r\n" . "(" . $ip_address . ")\r\n" . $theContent;
            fwrite($fh, $stringData);

            fclose($fh);

            }


            ?>

            • 3. Re: FLEX and PHP
              J_Fraser
              <mx:HTTPService id="userRequest" url=" http://localhost/TestApp/request.php" useProxy="false" method="POST">

              is that url pointing the the right location on your web server?