HELP: Getting input from perl cgi to PHP.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ray Muforosky

    HELP: Getting input from perl cgi to PHP.

    I have this:
    ------------

    print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\">\n";
    print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\ "></TD>\n";
    ..
    print "<INPUT type=\"HIDDEN\" name=\"year1\" >\n";
    print "<INPUT type=\"TEXT\" name=\"when\" >\n";
    print "</FORM>\n";

    if click on submit I get this:
    ------------------------------



    and I can't get the values here:
    --------------------------------

    <?php

    // set server access variables
    $when = $_REQUEST['when'];
    $year1 = $_REQUEST['year1'];
    ..
    ..
    echo $when;
    echo "<BR>";
    echo $year1;
    echo "<BR> The test ends here\n";
    ?>
    ---------------------------------
    What am I doing wrong?

    Thanks in advance.
    Ray

  • Justin Koivisto

    #2
    Re: HELP: Getting input from perl cgi to PHP.

    Ray Muforosky wrote:
    [color=blue]
    > I have this:
    > ------------
    >
    > print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\">\n";
    > print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\ "></TD>\n";
    > .
    > print "<INPUT type=\"HIDDEN\" name=\"year1\" >\n";
    > print "<INPUT type=\"TEXT\" name=\"when\" >\n";
    > print "</FORM>\n";
    >
    > if click on submit I get this:
    > ------------------------------
    > http://cpstmws2/p/cmdlog_rep.php?when=0&year1=
    >
    >
    > and I can't get the values here:
    > --------------------------------
    >
    > <?php
    >
    > // set server access variables
    > $when = $_REQUEST['when'];
    > $year1 = $_REQUEST['year1'];
    > .
    > .
    > echo $when;
    > echo "<BR>";
    > echo $year1;
    > echo "<BR> The test ends here\n";
    > ?>
    > ---------------------------------
    > What am I doing wrong?[/color]

    Try this:
    <?php
    echo '<pre>';
    print_r($_GET);
    echo'</pre>';
    ?>

    You should get something like:
    array(
    [when] = 0
    [year1] =
    )

    Then you can use:
    echo $_GET['when'],'<br>',
    $_GET['year1'],'<br>',
    'The test ends here';

    You might want to put in a method attribute for the form as well:
    print "<FORM name=\"form3\" method=\"get\" ACTION=\"cmdlog _rep.php\">\n";

    If you use "post" as the method, then change the $_GET to $_POST

    HTH

    --
    Justin Koivisto, ZCE - justin@koivi.co m

    Comment

    • Ray Muforosky

      #3
      Re: HELP: Getting input from perl cgi to PHP.

      Hello,

      I tried all as you wrote, but there was no output.
      ----------------------------------------------------------------------

      print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\"
      method=\"GET\"> \n";

      -----
      and
      ----
      print_r($_GET);

      echo $_GET['when'], "<BR>";
      ------------------------
      nothing.

      Comment

      • Rich

        #4
        Re: HELP: Getting input from perl cgi to PHP.

        In article <1123692671.904 969.3540@z14g20 00cwz.googlegro ups.com>, Ray Muforosky
        says...[color=blue]
        >
        >Hello,
        >
        >I tried all as you wrote, but there was no output.
        >----------------------------------------------------------------------
        >
        >print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\"
        >method=\"GET\" >\n";
        >
        >-----
        >and
        >----
        >print_r($_GET) ;
        >
        >echo $_GET['when'], "<BR>";
        >------------------------
        >nothing.
        >[/color]

        On your Perl CGI form you might need to specify the "when" value as a hidden
        form field or as part of the action's address. As an example if you use the
        action I believe you need to specify the key's value similar to
        "cmdlog_rep.php ?when=VALUE".

        Once the cmdlog_rep.php program gets it, weather it was sent from a PHP or Perl
        page you should be able to retrieve the information using the $_GET['when']
        variable.

        Rich
        --
        Newsguy.Com - Spot Account / 3 Days / 3GB / $3.99
        Complete posts and long retention times
        Bienvenue sur notre site d'actus et d'information francophone. Retrouvez chaque semaine les actus les plus folles et les plus captivantes de la toile.


        Comment

        • Justin Koivisto

          #5
          Re: HELP: Getting input from perl cgi to PHP.

          Ray Muforosky wrote:[color=blue]
          > Hello,
          >
          > I tried all as you wrote, but there was no output.
          > ----------------------------------------------------------------------
          >
          > print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\"
          > method=\"GET\"> \n";
          >
          > -----
          > and
          > ----
          > print_r($_GET);
          >
          > echo $_GET['when'], "<BR>";
          > ------------------------
          > nothing.
          >[/color]

          Are you getting errors in your log file? If you are getting nothing,
          then the script isn't executing because you should at least see the test
          end statement...

          --
          Justin Koivisto, ZCE - justin@koivi.co m

          Comment

          • Ray Muforosky

            #6
            Re: HELP: Getting input from perl cgi to PHP.

            I'm not getting any errors. Below is the code from perl cgi
            ------------------------------------------------------------------------------------------
            print "<HR>";
            print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\"
            method=\"GET\"> \n";
            print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\ "></TD>\n";

            print "<INPUT type=\"HIDDEN\" name=\"when\" VALUE= \"0\" >\n";
            print "<INPUT type=\"HIDDEN\" NAME=\"year1\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"year2\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"month1\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"month2\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"day1\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"day2\" > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"command\ " > \n";
            print "<INPUT type=\"HIDDEN\" NAME=\"event\" > \n";
            print "<TD><INPUT TYPE=\"checkbox \"NAME=\"erepor t_fmt\"VALUE=
            \"rpt\">Even t Report Format</TD>\n";
            print "<TD><INPUT TYPE=\"checkbox \"NAME=\"crepor t_fmt\"VALUE=
            \"rpt\">Comm and Report Format</TD>\n";
            print "</FORM>\n";

            Below is the code from the php
            --------------------------------------------
            //Get data
            $when = $_GET['when'];
            echo "<BR> This is a test\n"; <============== == This prints
            print_r($_GET);

            echo $_GET['when'], "<BR>";
            echo $_POST['when'], "<BR>";

            echo $when, "<BR>";
            echo "<BR> The test ends here\n"; <========= This prints
            -----------------------------------------------------
            This is what I get below
            -----------------------------------

            This is a test



            The test ends here
            ----------------------------------------- with no errors

            Comment

            • Justin Koivisto

              #7
              Re: HELP: Getting input from perl cgi to PHP.

              Ray Muforosky wrote:
              [color=blue]
              > I'm not getting any errors. Below is the code from perl cgi
              > ------------------------------------------------------------------------------------------
              > print "<HR>";
              > print "<FORM name=\"form3\" ACTION=\"cmdlog _rep.php\"
              > method=\"GET\"> \n";
              > print "<TD><INPUT TYPE=\"submit\" VALUE=\"Submit\ "></TD>\n";
              >
              > print "<INPUT type=\"HIDDEN\" name=\"when\" VALUE= \"0\" >\n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"year1\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"year2\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"month1\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"month2\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"day1\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"day2\" > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"command\ " > \n";
              > print "<INPUT type=\"HIDDEN\" NAME=\"event\" > \n";
              > print "<TD><INPUT TYPE=\"checkbox \"NAME=\"erepor t_fmt\"VALUE=
              > \"rpt\">Even t Report Format</TD>\n";
              > print "<TD><INPUT TYPE=\"checkbox \"NAME=\"crepor t_fmt\"VALUE=
              > \"rpt\">Comm and Report Format</TD>\n";
              > print "</FORM>\n";
              >
              > Below is the code from the php
              > --------------------------------------------
              > //Get data
              > $when = $_GET['when'];
              > echo "<BR> This is a test\n"; <============== == This prints
              > print_r($_GET);
              >
              > echo $_GET['when'], "<BR>";
              > echo $_POST['when'], "<BR>";
              >
              > echo $when, "<BR>";
              > echo "<BR> The test ends here\n"; <========= This prints
              > -----------------------------------------------------
              > This is what I get below
              > -----------------------------------
              >
              > This is a test
              >
              >
              >
              > The test ends here
              > ----------------------------------------- with no errors
              >[/color]


              Try accessing the URL directly like:

              cmdlog_rep.php? when=right_now

              and then see what happens. If you still don't get any output for the
              variable, you should set error_reporting to E_ALL in php.ini and then
              examine your logs after making another request.

              --
              Justin Koivisto, ZCE - justin@koivi.co m

              Comment

              • Ray Muforosky

                #8
                Re: HELP: Getting input from perl cgi to PHP.

                After I had the change made , do I have restart apache?

                Comment

                • Ray Muforosky

                  #9
                  Re: HELP: Getting input from perl cgi to PHP.

                  After I had the change made , do I have restart apache?

                  Comment

                  • Justin Koivisto

                    #10
                    Re: HELP: Getting input from perl cgi to PHP.

                    Ray Muforosky wrote:[color=blue]
                    > After I had the change made , do I have restart apache?
                    >[/color]
                    yes

                    --
                    Justin Koivisto, ZCE - justin@koivi.co m

                    Comment

                    • Ray Muforosky

                      #11
                      Re: HELP: Getting input from perl cgi to PHP.

                      No luck, still no errors

                      Comment

                      • Rich

                        #12
                        Re: HELP: Getting input from perl cgi to PHP.

                        In article <1123705034.168 326.82040@g14g2 000cwa.googlegr oups.com>, Ray Muforosky
                        says...[color=blue]
                        >
                        >No luck, still no errors
                        >[/color]

                        I think the way Perl CGI and PHP handle form data differs a little. If you are
                        using the $_GET variables they may be limited in use to the the URL in your
                        form's action. If you are trying to get form data from input fields (hidden or
                        not), you might need to use the $_POST variables, and change your form's method
                        to "post" instead. That or dynamically changing the "get" form's action so it
                        includes the necessary values in the URL for the $_GET variables to work.

                        Rich
                        --
                        Newsguy.Com - 30 GB - $14.95 / month
                        Complete posts and long retention times
                        Bienvenue sur notre site d'actus et d'information francophone. Retrouvez chaque semaine les actus les plus folles et les plus captivantes de la toile.


                        Comment

                        Working...