sourcecode
andyselby
<code>
#!/usr/bin/perl -w
#entry.cgi
use CGI qw/:standard/;
use FileHandle;
print header,
start_html('Title goes here');#feel free to change this
if (!param) {
print h1('header goes here'),
start_form(-action=>""),
"Enter name here", textfield('name')," i.e. andy selby",
p(),
"Enter your email addy if different from your name", textfield('email'),"\@youremailaddress.com",
p(),
"Monday",popup_menu(-name=>'monday',
-values=>['yes','no','probably','preferred']),#feel free to suggest more p(),
"Tuesday",popup_menu(-name=>'tuesday',
-values=>['yes','no','probably','preferred']),
p(),
"Wednesday",popup_menu(-name=>'wednesday',
-values=>['yes','no','probably','preferred']),
p(),
"Thursday",popup_menu(-name=>'thursday',
-values=>['yes','no','probably','preferred']),
p(),
"Friday",popup_menu(-name=>'friday',
-values=>['yes','no','probably','preferred']),
p(),
"Saturday",popup_menu(-name=>'saturday',
-values=>['yes','no','probably','preferred']),
p(),
"Sunday",popup_menu(-name=>'sunday',
-values=>['yes','no','probably','preferred']),
p(),
submit,
end_form;
}else{
open (OUT, ">>availability.csv") or die "$!";#output to csv file
print OUT join ",", map { param($_) } qw/name email monday tuesday wednesday thursday friday saturday sunday/;
print OUT "\n";
p(),
close OUT;
}
print "<a href=\"display.cgi\">click here to view results</a>";#redirect doesn't work, keeps 302'ing
print end_html;
####################################################
#!/usr/bin/perl -w
#display.cgi
use strict;
use warnings;
use CGI qw/:standard :html3/;
print header;
print start_html('title goes here');#feel free to change this title
print h1('header goes here');
print CGI::start_table();
print caption('The Following people are available thus'),
print TR({},
th([
'Name', 'Email', 'Monday', 'Tuesday', 'Wednesday',
'Thursday','Friday', 'Saturday', 'Sunday'
]),
);
open(my $DOC, "<", "availability.csv") or die "$!";
while(<$DOC>) {
chomp;
my @fields = split /\s*,\s*/;
print TR({},
td([
$fields[0], $fields[1], $fields[2], $fields[3], $fields[4],
$fields[5], $fields[6], $fields[7], $fields[8]
]),
);
}
close $DOC;
print CGI::end_table();
print end_html();
</code>
A script (two actually) that is used to display the availability of members on each weekday so that a date may be decided on when the maximum amount of memebers are available.
see it in action at webplus.andy.abel.co.uk/cgi-bin/entry.cgi
Split the code into two files at the line of hashes.
Done with a lot of help from batman on #miltonkeynes.pm
CGI Programming