Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force a re-submit from the user ??

Status
Not open for further replies.

SFBassman

Programmer
Jan 15, 2003
3
US
Using CGI, Perl and not using SSI how can one force the
visitors to re-submit data from a form on a simple HTML web page before they can see the results page. What code is needed in the CGI program before it prints the results page?
 
a really over simplified example of accepting an input, requesting confirmation and then saying thanks....
Code:
#!/usr/local/bin/perl
use CGI;
use CGI::Carp 'fatalsToBrowser';
use strict;

my $cgi = new CGI;
print $cgi->header,
      $cgi->start_html,
      $cgi->start_form;
      
my $parm = $cgi->param('parm');
# Three possible cases.
# 1 - no interaction yet -> give input page
# 2 - input page submitted -> confirm input
# 3 - confirmation submitted -> accept as final

# if 'resub', the first input page has been submitted
if ($parm eq 'confirm')
    {
    print qq(<p>You submitted: $parm<br />
             If correct, please continue.<br />),
          $cgi->submit(-name=>'submit',
                       -value=>'Continue'),
          qq(</p>);
    }
elsif ($cgi->param('submit') eq 'Continue')
    {
    print qq(<p>Thanks</p>);
    }
else 
    {
    print $cgi->popup_menu(-name=>'parm',
                            -values=>['confirm','don\'t care','another'],
                            -default=>'confirm'),
          $cgi->submit(-name=>'submit',
                        -value=>'submit');
    }
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top