in reply to Calling two scripts.

<!-- Name as script0.cgi --> <html> <body> <H1>Please click both buttons below in quick succession. (Thanks.)</ +H1> <form method=POST action=http://localhost/cgi-bin/script1.cgi> <button type=SUBMIT /> </form> <form method=POST action=http://localhost/cgi-bin/script2.cgi> <button type=SUBMIT /> </form> </body> </html>

Replies are listed 'Best First'.
Re: Re: Calling two scripts.
by The Mad Hatter (Priest) on May 04, 2003 at 23:40 UTC
    Uh, I don't think that will work. The browser might send both requests, but only data from one will be returned. Besides the technical problems, you really don't want to require your users to click two buttons in rapid succession.

      :)

Re: Re: Calling two scripts.
by nasa (Beadle) on May 05, 2003 at 05:13 UTC
    Dear Anonymous Monk,
    You have restored my belife, that all programers have a unique sense of humour.
    Thank you all for everything in the past.
    I actually pulled the counter script apart and inserted the following on the end of Script1.
    $filename = 'hits.data'; $main_dir = 'C:/Apache2/cgi-bin/sample'; $autoadd=1; $view_log='***********'; &FormInput(*input); $addnew=0; $lock = "$main_dir/count_lock.lock"; if ($input{'view'} ne $view_log) { &SetLock; } open(DATA,"$main_dir/$filename"); @lines = <DATA>; close(DATA); if ($input{'view'} eq $view_log) { } else { open(DATA,">$main_dir/$filename"); foreach $line (@lines) { ($link_url, $link_count1) = split(/\|/,$line); if ($input{'url'} eq $link_url1) { $link_count1++; print DATA ("From the Sample script.|$link_count1\n"); $addnew=1; } else { print DATA $line; } } if ($addnew == 0 && $autoadd == 1) { print DATA ("$input{'url'}|1\n"); } &EndLock; close(DATA); if ($input{'url'} !~ m?://?) { $input{'url'} = "http://" . $input{'url'}; } } exit; sub FormInput { local (*qs) = @_ if @_; if ($ENV{'REQUEST_METHOD'} eq "GET") { $qs = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$qs,$ENV{'CONTENT_LENGTH'}); } @qs = split(/&/,$qs); foreach $i (0 .. $#qs) { $qs[$i] =~ s/\+/ /g; $qs[$i] =~ s/%(..)/pack("c",hex($1))/ge; ($name,$value) = split(/=/,$qs[$i],2); if($qs{$name} ne "") { $qs{$name} = "$qs{$name}:$value"; } else { $qs{$name} = $value; } } return 1; } sub SetLock { $timecheck = 0; while(-e $lock) { sleep(5); $timecheck = $timecheck + 1; if ($timecheck >= 5) { unlink("$lock"); } } open(LOCKFILE,">$lock"); close(LOCKFILE); return; } sub EndLock { unlink("$lock"); return; }

    there would be much more left there than I really need .
    But it workes wonderfully fine .
    So I am happy.
    Nasa.