On Tuesday, Feb 18, 2003, at 08:43 US/Pacific, Scott Lutz wrote:
What I am attempting to do, is do a server side "form action" redirect based on a regex on a field from the form.
[..]
[Mon Feb 17 17:04:05 2003] [error] [client 66.51.160.131] Premature end of script headers: /var/cgi-bin/parse.cgiassuming that the above is your script there is the
Any help with what might be missing would be great
Here is the script:
#!/usr/bin/perl -wT
use strict;
use HTTP::Request::Common;
use LWP::UserAgent;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $q = new CGI;
my $ua = LWP::UserAgent->new;
if ($q->param("domain") =~ /\.ca$/) {
$ua->request(POST 'https://domains/perl/ca_reg.cgi', [
domain => $q->param("domain"),
affiliate_id => $q->param("affiliate_id"),
action => $q->param("lookup"),
]);
} else {
$ua->request(POST 'https://domains/perl/reg_system.cgi', [
domain => $q->param("domain"),
affiliate_id => $q->param("affiliate_id"),
action => $q->param("lookup"),
]);
}
Please do not hesitate to contact me directly if you have any more questions!
minor problem that it is not sending anything back to
the browser.... which is the 'exit prematurely' argument
what you will want to do is send a redirect back to
the browser to query the other scripts...
the other alternative is to use a piece of javascripting
that will resolve this on the client side before sending
a request back to the server.
you can think of this in terms of say
my @targets = qw(ca_reg.cgi ca_system.cgi);
my $index = 0;
my $jscript = '<script language="JavaScript" type="text/javascript">
<!--
function doit(){
var base_uri = "https://domains/perl/";
var urls=new Array();' ."\n";'
foreach my $targ (@targets)
{
$jscript .= 'urls[' . $index++ . ']="' . $targ . "\";\n";
}
$jscript .= 'var nChosen = document.FormName.sysname.selectedIndex;
var wordup = base_uri + urls[nChosen];
document.FormName.action= wordup;
document.FormName.method = "POST";
return true;
}
//-->
</SCRIPT>';
my $form = '<form name="FormName" action="../" onsubmit="doit()" target="_top">'
#
# the part where you stuff in the 'hidden values' you want,
# such as the domain,affiliate_id, etc... or put them in
# other things that this 'form' would send back
#
......
If you put that '$jscript' into the <head>...</head>
and show your 'form' in the <body>...</body>
when you user 'submits' it will go through the 'javascript'
to resolve the 'real method' and sent the Post to
the two scripts.
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
