473,574 Members | 2,817 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1914
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.co m
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************ ********@z14g20 00cwz.googlegro ups.com>, 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.co m
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=\"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

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=\"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

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.co m
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.co m
http://koivi.com
Aug 10 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2885
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 is the number of printed characters; so if I could somehow get my year variable to store the leading zeros, I could just run a check: int dummy =...
1
1254
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 is what I expected one.
1
1286
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 xp pro os.This program is suppose to make a modified copy of a text file. In the copy ,every string Fred should be replaced with Larry. I want to...
1
2108
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 been seen or if the value for an object is outside of the min/max range. i.e. assume from 10 days input the value for "size" ranges from 10-18, I...
5
5733
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 out. Corrections would be highly appreciated. The code: use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser...
5
1938
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 of the DB and not what is selected. I am all messed up..I know this is straight forward but I am having a real hard time with this. I am wanting...
6
1983
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 http://nonsense.sourceforge.net/): ### Load and parse a datafile, slurping the contents into the %pool hash sub LoadDataFile { my $file = shift; $file = SafeFile(...
4
2140
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 my fpga design work. I tried rectifying the errors that occurred - added the semicolon in line 459 , removed the brackets in line 460 and aligned the...
3
1991
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 field1 ╤ field2 initially i have written a code to get the below lines in my program hex.pl
0
7832
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8262
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8129
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5331
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2262
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1364
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1094
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.