Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

member availability entry and display script

by andyselby (Acolyte)
on Dec 12, 2007 at 11:43 UTC ( #656595=sourcecode: print w/replies, xml ) Need Help??
Category: CGI Programming
Author/Contact Info
Description: 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
#!/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 su
+ggest 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 wed
+nesday thursday friday saturday sunday/;
print OUT "\n";
p(),

close OUT;
}
print "<a href=\"display.cgi\">click here to view results</a>";#redire
+ct 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], $fie
+lds[4],
                  $fields[5], $fields[6], $fields[7], $fields[8]
              ]),
          );
}

close $DOC;

print CGI::end_table();
print end_html();
Replies are listed 'Best First'.
Re: member availability entry and display script
by ForgotPasswordAgain (Priest) on Dec 12, 2007 at 12:08 UTC
    I don't mean to be overly negative, but.... I'd expect to see something like that if it was 1995. Note: it's 2007. I'd much rather use something like Doodle, though even that is kind of outdated with its pre-ajaxian page refreshes.
      ...well I am a bit of a perl newbie and this is my first try at writing code that other people will use.
      I'd much rather use something like Doodle,
      Now had I known that existed I would not have wrote this.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://656595]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2021-01-24 23:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?