#!/usr/bin/perl use CGI qw(:standard); # http header print header; if (! param()) { # if the form hasn't been submitted yet... # the title print start_html('A Registration Form Example'), h1('A Registration Form Example'), p, "this form is about: ", query_string, start_form, "What's your name? ", textfield('name'), br, "Email address: ", textfield(-name=>'email', -size=>20), p, "What courses are you attending?", p, checkbox_group(-name=>'courses', -values=>['perl','CGI','web mastering','crisis mgmt'], -defaults=>['web mastering','crisis mgmt']), p, "What ", strong("color"), " rental car will you need? ", popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']), p, "Any comments ?", textarea(-name=>'comments', -rows=>4, -columns=>50), p, submit(-name=>'action',-value=>'Submit Registration'), end_form, hr; } # the form has been submitted else { print "Your name is ", em(param('name')), ", at email address: ", tt(param('email')), p, "The courses you selected are are: ", join(", ", param('courses')), p, "Your rental car will be ", strong(param('color')), " in color.", p, "Your comments are: ", br, param('comments'), hr; open(S, ">/tmp/soup"); # open a file to write to $CGI::Q->save(S); # dump out all the form info close(S); # close the file } # stuff to print if the form has been filled out or not print address( a({-href=>'http://h2o.usgs.gov/'}, 'Home page') ); print end_html();