in reply to Updated Button Question

If I understand correctly, you want to send the parameters both to your script (so you can print them) and to a second script (submitq). That's quite tricky because HTTP & HTML designers failed to forsee the need to do a POST redirection. If you only needed to send it to submitq, then you could:

<form ...> <center><input type=submit value=Send name=S1></center> </form>

to:

<form method="POST" action="http://.../submitq.cgi"> <center><input type=submit value=Send name=S1></center> </form>

One way would be to get JavaScript to do a post by changing:

# When it is print # Redirect to another web page if (param('S1') eq "Send") { print BOBIN $datajoin; print redirect("http://.../submitq.cgi"); }

to:

if (param('S1') eq "Send") { print BOBIN $datajoin; <body onload="form1.submit()"> <form name="form1" method="POST" action="http://.../submitq.cg +i"> foreach ($cgi->params()) { <input type=hidden name="$_" value="$cgi->param($_);" > } </form> }

Another alternative is a "subquery". Change:

# When it is print # Redirect to another web page if (param('S1') eq "Send") { print BOBIN $datajoin; print redirect("http://.../submitq.cgi"); }

to:

if (param('S1') eq "Send") { print BOBIN $datajoin; require LWP::UserAgent; require HTTP::Request::Common; $ua = ...; $ua->request(POST 'http://.../submitq.cgi', [ params ]); print the response. }

As an aside, open(FH, ">>...") will create the file if necessary, so

if (-e $datefile) { open (BOBIN, ">>$datefile") || die "Cannot Open File $datefile for + writing: $!"; # Open Data file } else { ### Else open directory where files data files are located # Sort in descending order, pick out first file # And e-mail it # Then create a new file with current data as name open (BOBIN, ">$datefile") || die "Cannot create File $datefile f +or writing: $!"; }

simplifies to

open (BOBIN, ">>$datefile") || die "Cannot Open File $datefile for + writing: $!"; # Open/Create Data file

Replies are listed 'Best First'.
Re^2: Updated Button Question
by Midnite (Acolyte) on Aug 12, 2004 at 15:16 UTC
    ikegami,

    Actually, all I want is to be able to write the data, and redirect to new web page say it was done.

    If you know of another way other than using param, it would be great. If not, all I need is the one field wriiten to the txt file.

    I can do it straight, by just writing it as soon as the web page is created, but I want to give them a choice wether to write it or correct it, then write it.

    Joseph A. Ruffino
    Automated Systems Assistant
    Gail Borden Public Library District
    270 N. Grove Ave
    Elgin, Il, 60120
    847-742-2411 x5986

      Actually, all I want is to be able to write the data, and redirect to new web page say it was done.

      Doesn't your code already do that?

      If you know of another way other than using param, it would be great. If not, all I need is the one field wriiten to the txt file.

      The server has to be able to tell what you want to do. One option is to use a param like you did. That's very proper.

      Another way is is by having multiple scripts. Specifically, script2.cgi would be the contents of if (param('S1') eq "Send") block, and script1.cgi would have the rest. script1.cgi would specify script2.cgi in the action field of the of the <form> element.

      It's a question of prefence, but checking the param like you are already doing is probably the most straightforward.

        It does redirect to another web page, but does not write the data

        I am tryin the two script method, but it is not passing the data like I want. I did submit a new question on that also called Sending Data

        Joseph A. Ruffino
        Automated Systems Assistant
        Gail Borden Public Library District
        270 N. Grove Ave
        Elgin, Il, 60120
        847-742-2411 x5986