fork download
  1. #!/usr/bin/perl
  2. # " " " or use http://d...content-available-to-author-only...m.com/tools/smart-quotes.html to convert all smart quotes to straight #quotes
  3. require "subparseform.lib";
  4. use warnings;
  5. use strict;
  6. use CGI;
  7.  
  8.  
  9. my $bgcolor = "green";
  10. my $filledcellcolor = "yellow";
  11. my $emptycellcolor = "pink";
  12. my $tablecols = 3;
  13. my $tablerows = 20;
  14. my ($i,$j);
  15.  
  16. #opens file p04.txt for writing
  17. open(MYFILE, "p04.txt") or die("\nError: cannot open file\n");
  18.  
  19. my @name = <MYFILE>;
  20. chomp(@name);
  21. close(MYFILE);
  22.  
  23.  
  24. my $parseCount;
  25.  
  26.  
  27. &Parse_Form;
  28.  
  29. #this needs to be in a for loop that runs through the elements in an array
  30. #if($formdata{"text$parseCount"} eq ""){
  31. #$table[$parseCount] = $formdata{"text$parseCount"};
  32. #}
  33.  
  34. my $cgi = CGI->new; #Instantiate a CGI class
  35. print $cgi->header,
  36.  
  37. #begin html page
  38. $cgi->start_html('Super Bowl Party'),
  39.  
  40.  
  41. # create the Tag <h1>TEXT</h1>
  42. $cgi->h1("<center>Super Bowl Party Sign-up Sheet</center>"),
  43.  
  44. #header
  45. $cgi->h2("<center>Project p04</center>"),
  46.  
  47. #header
  48. $cgi->h3("<center>Adam Knutson</center>"),
  49. $cgi->start_form();
  50. print "<center><TABLE BORDER=1>";
  51.  
  52.  
  53. #creates 3 columns and 20 rows of text boxes
  54. my $count = 0;
  55. for ($j = 0; $j <$tablerows; $j++)
  56. {
  57. print "<TR>";
  58. for ($i = 0;$i < $tablecols; $i++)
  59. {
  60. if ( $name[$count] eq "" )
  61. {
  62. print "<TD BGCOLOR='".$filledcellcolor."' > <INPUT TYPE=TEXT NAME='text".$count."' SIZE=40 MAXLENGTH=50 VALUE='' background-color:'".$emptycellcolor."'> </TD>";
  63. }
  64. else
  65. {
  66. print "<TD> $name[$count]</TD>";
  67. }
  68. $count++;
  69. }
  70. print "</TR>";
  71. }
  72.  
  73.  
  74. open (MYFILE, '>p04.txt');
  75. my $newCount = 0;
  76.  
  77. #while conditions don't use 59, use number of columns*number of rows.
  78. while ($newCount <59){
  79. print MYFILE "$name[$newCount] \n";
  80. #print MYFILE "\n";
  81. $newCount ++;
  82. }
  83. close (MYFILE);
  84.  
  85. #Creates submit and reset buttons at bottom of page
  86. print "</TABLE> <INPUT TYPE=submit NAME=submitButton VALUE='Submit Form'>
  87.  
  88. <INPUT TYPE=reset NAME=resetButton VALUE='Clear Form'>
  89. </center>";
  90.  
  91. #print $cgi->end_form();
  92. $cgi->h2("<center>Project p04</center>"),
  93. $cgi->end_html; #end of HTML
  94.  
  95.  
Runtime error #stdin #stdout 0.01s 5420KB
stdin
Standard input is empty
stdout
Standard output is empty