homepage Welcome to WebmasterWorld Guest from 174.129.80.166
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Autoposting a form from one .pl file to another
I know how to do it in PHP/javascript
le_gber




msg:3877474
 8:24 am on Mar 24, 2009 (gmt 0)

First of all, let's just be honest. I know NOTHING about perl. I did try to get my head round it but I am no perl - or other - programmer.

Basically I need to be able to post a form to a .pl file and on that pl file nothing happens other that autoposting it to another perl file.

In PHP I would do something like:

<?php
if($_POST()}{

echo '<form method="post" action="other_perl_script.pl">;

foreach($_POST as $key => $value){
echo '<input type="hidden" name="'.&key.'" value="'.$value.'" />;
}

echo '</form>';

}
?>

and have <body onload="form[0].submit()"> or something similar.

I did try using LWP::UserAgent; or the PHP:interpreter but with no luck. I just don't get perl.

 

rocknbil




msg:3878067
 11:36 pm on Mar 24, 2009 (gmt 0)

First, check your error logs.

Next, if that provides no love, verify the script works. Install perl on your local machine. From command line/DOS, type perl other_perl_script.pl (press enter.) You should see either script output or errors, and it will tell you approximately where to look.

If the script is fine, find out how and where it's reading and parsing the variables. This is done automatically in PHP, giving you $_POST, $_GET, or $_REQUEST. So somewhere will be something like

%data = &read_parse;

Where read_parse is the R/P routine, and now %data is the associative array (hash, in perl-ese) storing all the input values.

I've used %data as an example here, it can be any variable name. Some really lousy scripts do the read/parse inline, but it should be relatively easy to find.

Once you reach this point, paste this *immediately* after the %data variable has been populated:

print "content-type:text/html\n\n";
print "Test <br>\n";
foreach $k (keys %data) { print "key: $k value: $data{$k}<br>\n"; }
exit 0;

Subsitituting, of course, the hash name in your program for "data."

( The above is the semi-equivalent of var_dump($data) )

Try your script with this in place. If all you see is the word "test" you know a) the script is syntactically correct, but b) something in it is broken and it's not parsing out the form data.

If you see a list of the values you submitted, you know it's both syntactically correct and accepting data, but it's broken somewhere else. Move this chunk of code successively down through your script until you find out where it's breaking.

le_gber




msg:3878516
 3:41 pm on Mar 25, 2009 (gmt 0)

Thank you for your reply rocknbil, I'll give this a go.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved