in reply to field deletion after a submit

First, start by defining a CGI object. Now the rest of the param and form element references in the script should be edited accordingingly with a $query->. Next move the data handling code to the top of your script and simply execute a $query->delete_all(); when you are done with it. This will clear your form data before it is printed again.

Kinda like this:

#!/usr/bin/perl use CGI qw/:standard/; $query= new CGI; if ($query->param()) { open (CFGFILE,">>mothership.cfg") || die; print CFGFILE (param('name')),",", ($query->param('ip')),",", ($query->param('port')),",", ($query->param('proto')),",", ($query->param('desc')), "\n"; close CFGFILE; $query->delete_all(); } print header, start_html('Mothership Connection'), h1('Mothership Connection Configuration'), $query->start_form, "Server Name ",$query->textfield('name'),p, "IP Address ",$query->textfield('ip'),p, "Port Number",$query->textfield('port'),p, $query->checkbox_group(-name=>'proto', -values=>['tcp','udp']),p, "Description",$query->textfield('desc'),p, $query->submit('submit'), $query->end_form, hr;

Replies are listed 'Best First'.
Re: Re: field deletion after a submit
by Anonymous Monk on Apr 29, 2003 at 04:22 UTC
    Thanks! That helped a lot.