6 Replies Latest reply on Oct 5, 2009 10:54 PM by kglad

    LoadVars

    Ron Colmen Level 2

      This is my script in trying to send data to the server side PHP

       

      var senderLoad:LoadVars = new LoadVars();
      var receiveLoad:LoadVars = new LoadVars();

       

      sender.onRelease = function () {
      senderLoad.urlText = urlText.text;
      senderLoad.sendAndLoad("http://www.abc.com/dyomails.php",receiveLoad);

      receiveLoad.onLoad = function () {

       

      \\ QUESTION: How do I write a SUCCESS and FAILED confirmation using gotoAndPlay to interact with the PHP?
      }
      }

        • 1. Re: LoadVars
          kglad Adobe Community Professional & MVP

          your php should echo something back indicating success or failure.  and use onData() while testing and define it before calling the php script:

           

           

          var senderLoad:LoadVars = new LoadVars();
          var receiveLoad:LoadVars = new LoadVars();

          receiveLoad.onData = function (src) {

           

          trace(src);
          }

           

           

          sender.onRelease = function () {
          senderLoad.urlText = urlText.text;
          senderLoad.sendAndLoad("http://www.abc.com/dyomails.php",receiveLoad);



          }

          1 person found this helpful
          • 2. Re: LoadVars
            Ron Colmen Level 2

            Thanks once again. But still in trouble!

             

            This is my PHP Code (I'm sure it's correct)
            <?php
            $link = mysql_connect("localhost","imy","ipwpw");
            mysql_select_db("imy_dyomails");

             

            $query = 'SELECT * FROM dyomails';
            $results = mysql_query($query);

             

            echo "<?xml version=\"1.0\"?>\n";
            echo "<dyomails>\n";

             

            $SomeVar = "$urlText";

            $query = "SELECT * FROM dyomails WHERE ID = '$SomeVar'";
            $results = mysql_query($query);
              if($line = mysql_fetch_assoc($results))
            {
              echo = "<item>" . $line["Email"] . "</item>\n";
            }

            echo "</dyomails>\n";
            mysql_close($link);

            ?>

             

             

             

            AS code:

            var theXML:XML = new XML();
            theXML.ignoreWhite = true;

            theXML.onLoad = function() {
            var nodes = this.firstChild.childNodes;
            for(i=0;i<nodes.length;i++) {
              dismail.addItem(nodes[i].firstChild.nodeValue,i);
            }
            }

            theXML.load("http://www.myweb/dyomails.php");

             

            The idea here is to send the URL and match it to an ID on the MySQL db and return the correct email back to flash. BUT I'm not receiving the EMAIL ADDRESS in to my text box?

            • 3. Re: LoadVars
              kglad Adobe Community Professional & MVP

              use loadvars to call a php script like you were doing in your previous message and use the changes i suggested.

              1 person found this helpful
              • 4. Re: LoadVars
                Ron Colmen Level 2

                The PHP script is shown in the earlier post. As you suggested I've put in a echo. Please tell me whether this is correct? if not hhow to script echo in PHP and flash?

                 

                var senderLoad:LoadVars = new LoadVars();
                var receiveLoad:LoadVars = new LoadVars();

                receiveLoad.onData = function (src) {
                trace(src);
                }

                sender.onRelease = function () {
                senderLoad.fin = fin.text;
                senderLoad.sendAndLoad("http://abc.com/dyomails.php",receiveLoad);
                }

                 

                receiveLoad.onLoad = function () {
                if(this.Email) {
                  _root.gotoAndStop("success");
                }
                else {
                  _root.gotoAndStop("failed");
                }
                }

                • 5. Re: LoadVars
                  Ron Colmen Level 2

                  Thanks for the guidence!! I did it!   

                   

                  Here's your $10 sir.

                  • 6. Re: LoadVars
                    kglad Adobe Community Professional & MVP

                    you're welcome.

                     

                    if you can, please mark this thread as answered.