469,318 Members | 1,926 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,318 developers. It's quick & easy.

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:
------------------------------
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?

Thanks in advance.
Ray

Aug 10 '05 #1
11 1721
Ray Muforosky wrote:
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?


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 - ju****@koivi.com
http://koivi.com
Aug 10 '05 #2
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.

Aug 10 '05 #3
In article <11********************@z14g2000cwz.googlegroups.c om>, Ray Muforosky
says...

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.


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
http://newsguy.com/overview.htm

Aug 10 '05 #4
Ray Muforosky wrote:
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.


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 - ju****@koivi.com
http://koivi.com
Aug 10 '05 #5
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=\"ereport_fmt\"VALUE=
\"rpt\">Event Report Format</TD>\n";
print "<TD><INPUT TYPE=\"checkbox\"NAME=\"creport_fmt\"VALUE=
\"rpt\">Command 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

Aug 10 '05 #6
Ray Muforosky wrote:
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=\"ereport_fmt\"VALUE=
\"rpt\">Event Report Format</TD>\n";
print "<TD><INPUT TYPE=\"checkbox\"NAME=\"creport_fmt\"VALUE=
\"rpt\">Command 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

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 - ju****@koivi.com
http://koivi.com
Aug 10 '05 #7
After I had the change made , do I have restart apache?

Aug 10 '05 #8
After I had the change made , do I have restart apache?

Aug 10 '05 #9
Ray Muforosky wrote:
After I had the change made , do I have restart apache?

yes

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Aug 10 '05 #10
No luck, still no errors

Aug 10 '05 #11
In article <11*********************@g14g2000cwa.googlegroups. com>, Ray Muforosky
says...

No luck, still no errors


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
http://newsguy.com/overview.htm

Aug 11 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Sivarn | last post: by
1 post views Thread by kirankv123 | last post: by
4 posts views Thread by rsaharia | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.