Hi. We had this problem on a machine before, I cant remember how we fixed it, now its happening on a different machine (redhat 7.2)
When I submit any data from a form to perl, perl cant read the STDIN or content length or query string so i cant get any of the data :( This is with many forms some written by me, some not. If i use index.cgi?action=a... it can read that but not info submitted by a form.
I've re-installed perl, anyone know what to do?
Thanks
AQHost
07-28-2002, 11:29 AM
Sounds to me as though the form is set to use the POST method and your script is trying to read data from a GET request. Hence the script can interpret action=a when sent as part of the URL (GET) but reads nothing from the form.
If your form uses POST, you can get the data from it as follows:
read (STDIN,$temp,$ENV{'CONTENT_LENGTH'});
@pairs=split(/&/,$temp);
foreach $item(@pairs)
{
($key,$content)=split (/=/,$item);
$content=~tr /+/ /;
$content=~s /%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}
If it uses GET, use this instead:
$temp=$ENV{'QUERY_STRING'};
@pairs=split(/&/,$temp);
foreach $item(@pairs) {
($key,$content)=split (/=/,$item,2);
$content=~s/%(..)/pack("c",hex($1))/ge;
$fields{$key}=$content;
}
Hope this solves your problem!
Simon.
No, not it :( (PS im not new to perl, ive been doing this for years - and its not only my scripts, its others as well)
i tried:
read (STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
both content_length and buffer are empty... :(
AQHost
07-28-2002, 11:34 AM
If you want to PM or email me with the form code, I'd be happy to upload it here and see if I can read the variables using one of the code snippets above? That'll at least narrow it down to the code or the server.
Simon.
Its the server. Again, its many many scripts that have worked before dont work now because of this.
chirpy
07-28-2002, 12:36 PM
Avi, just a thought, have you got a restrictive .htaccess on the /path/directory with a <Limit POST></Limit> somewhere in it?
chirpy
07-28-2002, 12:42 PM
A few other ideas:
Have you tried an environment script that dumps all the HTTP headers to make sure that others are present?
#!/usr/bin/perl
print "content-type: text/html\n\n";
print "<table>\n";
foreach my $key (keys %ENV) {
print "<tr><td>$key</td><td>$ENV{$key}</td></tr>\n";
}
print "</table>";
Have you tried a different browser? (Just incase you're using an old NutScrape).
It does sound more like an Apache config problem, I'd be suprised if it was anything to do with perl.
No .htaccess file BUT
When i put the whole variables thing infront of the script i see:
REQUEST_METHOD GET
which is odd, because the code has form method=post action=.....cgi
...why would it do that?
Damn apache!
:)
Story... our control panel was built on cobalt - cobalt uses rewrite rules - so what happened was for some reason the script was calling it as domain.com not www.domain.com so it called GET - i saw the access log, for ever request there was a post and then a get for the same page
anyway, i removed the redirect and its fixed. Thanks for the help guys