473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1893
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Sivarn | last post by:
I'm writing a program for that takes dates as input using scanf. I want to verify that the user is inputting a full 4 digits for the year. How do I do this? I know that the return value on printf...
1
by: kirankv123 | last post by:
Hi I am very much new to perl....plz help me in getting this ... $user = "Uservalue" $str = "somestring$user" If I tried to print $str - getting the result as somestringUservalue which...
1
by: gooop | last post by:
I am new to perl. I am having trouble with this code line I wrote. On thef fourth line I keep getting this message when I go to run this. . Please any advice would help.I am using TextPad, and window...
1
by: shawn828 | last post by:
I am eager to learn perl and I need help trying to write a script. I need to be able to parse a csv file daily and have the script store min/max values for objects then report if a new object has...
5
by: olaamussah | last post by:
Hi, i just started learning perl which i would use for my uni. project unfortunately. Well, this is a simple user login page i tried to create but i cant get it to work. Can someone please check this...
5
by: deppeler | last post by:
Can someone look at this for me: I am trying to set up a script to edit an item in a flat file DB but I don't seem to be getting the data to the Photoedit script. It seems to be reading the 1st line...
6
by: Paulchen | last post by:
Hello, I have found a perl script and need to "translate" this to PHP. I try to do it step by step and the first part of it is this function (the whole script is found at...
4
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
3
by: user1357 | last post by:
Hi All, i am trying to write a code which will take a non printable character as an input and used as a separator for different fields ex : if user gives an input \xd1 the o/p should be ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.