This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
SYN SYN
[perl5.git] / lib / CGI / eg / multiple_forms.cgi
CommitLineData
54310121 1#!/usr/local/bin/perl
2
3use CGI;
4
5$query = new CGI;
6print $query->header;
7print $query->start_html('Multiple Forms');
8print "<H1>Multiple Forms</H1>\n";
9
10# Print the first form
11print $query->startform;
12$name = $query->remote_user || 'anonymous@' . $query->remote_host;
13
14print "What's your name? ",$query->textfield('name',$name,50);
15print "<P>What's the combination?<P>",
16 $query->checkbox_group('words',['eenie','meenie','minie','moe']);
17print "<P>What's your favorite color? ",
18 $query->popup_menu('color',['red','green','blue','chartreuse']),
19 "<P>";
20print $query->submit('form_1','Send Form 1');
21print $query->endform;
22
23# Print the second form
24print "<HR>\n";
25print $query->startform;
26print "Some radio buttons: ",$query->radio_group('radio buttons',
27 [qw{one two three four five}],'three'),"\n";
28print "<P>What's the password? ",$query->password_field('pass','secret');
29print $query->defaults,$query->submit('form_2','Send Form 2'),"\n";
30print $query->endform;
31
32print "<HR>\n";
33
34$query->import_names('Q');
35if ($Q::form_1) {
36 print "<H2>Form 1 Submitted</H2>\n";
37 print "Your name is <EM>$Q::name</EM>\n";
38 print "<P>The combination is: <EM>{",join(",",@Q::words),"}</EM>\n";
39 print "<P>Your favorite color is <EM>$Q::color</EM>\n";
40} elsif ($Q::form_2) {
41 print <<EOF;
42<H2>Form 2 Submitted</H2>
43<P>The value of the radio buttons is <EM>$Q::radio_buttons</EM>
44<P>The secret password is <EM>$Q::pass</EM>
45EOF
46 ;
47}
48print qq{<P><A HREF="./">Other examples</A>};
49print qq{<P><A HREF="../cgi_docs.html">Go to the documentation</A>};
50
51print $query->end_html;
52
53
54