home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / eg / cgi / multiple_forms.cgi < prev    next >
Text File  |  1999-07-20  |  2KB  |  55 lines

  1. #!/usr/local/bin/perl
  2.  
  3. use CGI;
  4.  
  5. $query = new CGI;
  6. print $query->header;
  7. print $query->start_html('Multiple Forms');
  8. print "<H1>Multiple Forms</H1>\n";
  9.  
  10. # Print the first form
  11. print $query->startform;
  12. $name = $query->remote_user || 'anonymous@' . $query->remote_host;
  13.  
  14. print "What's your name? ",$query->textfield('name',$name,50);
  15. print "<P>What's the combination?<P>",
  16.         $query->checkbox_group('words',['eenie','meenie','minie','moe']);
  17. print "<P>What's your favorite color? ",
  18.         $query->popup_menu('color',['red','green','blue','chartreuse']),
  19.     "<P>";
  20. print $query->submit('form_1','Send Form 1');
  21. print $query->endform;
  22.  
  23. # Print the second form
  24. print "<HR>\n";
  25. print $query->startform;
  26. print "Some radio buttons: ",$query->radio_group('radio buttons',
  27.                          [qw{one two three four five}],'three'),"\n";
  28. print "<P>What's the password? ",$query->password_field('pass','secret');
  29. print $query->defaults,$query->submit('form_2','Send Form 2'),"\n";
  30. print $query->endform;
  31.  
  32. print "<HR>\n";
  33.  
  34. $query->import_names('Q');
  35. if ($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>
  45. EOF
  46.     ;
  47. }
  48. print qq{<P><A HREF="./">Other examples</A>};
  49. print qq{<P><A HREF="../cgi_docs.html">Go to the documentation</A>};
  50.  
  51. print $query->end_html;
  52.  
  53.  
  54.  
  55.