2 Replies Latest reply on Feb 12, 2007 9:24 AM by duckets

    Sending values from director to PHP

    ajeet.ghule
      Hi :-)
      I want to send values from director to the PHP page and then i want that PHP page to access those values.
      I need to know if it is possible in director to send values to php.

      I have read about the postNetText in director it takes two parameters ifrst as the Page url and second is the list of parameters.
      but my problem is how will the PHP page accept those parametes.
      Please give me any example if possible to demo this thing.

      Thanks and regards
      - Ajit
        • 1. Re: Sending values from director to PHP
          Lukewig Level 1
          Hi,

          In Lingo, you send using GET like this

          --LINGO
          netID = getNetText("http"//domain.com/script.php?Key=Value")

          to receive this in PHP, create a page called "script.php" at the above URL with this PHP code

          <?php
          $value = $_GET['Key'];
          echo "Received the value '$value'";
          ?>

          If you are sending a lot of data, then you can send it using the POST method like this:

          --LINGO
          data = ["Key":"Value"]
          netID = postNetText("http"//domain.com/script.php", data )

          to receive this in PHP, create a page called "script.php" at the above URL with this PHP code

          <?php
          $value = $_POST['Key'];
          echo "Received the value '$value'";
          ?>


          And if you want your PHP to work with either POST or GET, then you can write your PHP like this:

          <?php
          $value = $_REQUEST['Key'];
          echo "Received the value '$value'";
          ?>

          Its also helpful debugging you PHP by doing something like this:

          <?php
          // debug the request data
          echo "Received these POST values<hr />\n";
          print_r($_POST);
          echo " <hr />\nReceived these GET values <hr />\n";
          print_r($_GET);
          echo "\n <hr />\n";
          ?>

          -- Luke

          • 2. Re: Sending values from director to PHP
            duckets Level 1
            If, for example, you send the following data:

            dataList = [ "name" : "Ben", "age": 29 ]
            netID = postNetText(" http://example.com/script.php", dataList)

            In your php script, check the $_POST array like this:

            $name = $_POST['name'];
            $age = $_POST['age'];

            hope this helps!

            - Ben