Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/local/bin/perl # $Id: class-schedule-form.cgi,v 1.7 2004/08/18 18:31:12 hossman Exp $ # $Source: /home/hossman/cvs_archive/code/perl/class-scheduler/class-s +chedule-fo rm.cgi,v $ # use warnings; use strict; use Fcntl qw(:flock :seek); use CGI; use vars qw($file $thank); use vars qw($email $fname $lname $sid $status @sections $none); use vars qw($q @err); # the file all of our data goes to $file = "./class-schedule-data.txt"; # the thank you page $thank = "./thanks.html"; eval { $q = new CGI; # get our section list, ensure all be numbers # (don't bother reporting errors, only comes from spoofers, so fuc +k them) @sections = $q->param('section'); $_ =~ s/[^\d]//g foreach @sections; # get all vals, and strip out colon, and line enders ($email = $q->param('email') || '') =~ s/:|\n|\r//g; ($fname = $q->param('fname') || '') =~ s/:|\n|\r//g; ($lname = $q->param('lname') || '') =~ s/:|\n|\r//g; ($sid = $q->param('sid') || '') =~ s/:|\n|\r//g; ($status = $q->param('status') || '') =~ s/:|\n|\r//g; ($none = $q->param('none') || '') =~ s/:|\n|\r//g; push @err, "You must specify a valid Student ID" unless $sid =~ /^\d+$/; push @err, "You must specify your First Name" unless $fname =~ +/.+/; push @err, "You must specify your Last Name" unless $lname =~ +/.+/; push @err, "You must specify your Email Address" unless $email =~ +/.+/; push @err, "You must specify your Enrollment Status" unless $status =~ /^(W|E|N)$/; if (0 == @sections and ! $none) { push @err, "You must check the sections you can attend " . "or indicate that you can't attend any"; } elsif (0 < @sections and $none) { push @err, "You can not check sections that you can attend " . "AND indicate that you can't attend any"; } die "User Input Errors" if @err; # lock our file, and write out to it open(FILE, ">>$file") or die "couldn't open data file to append"; flock(FILE, LOCK_EX) or die "can't lock data file"; seek(FILE, 0, SEEK_END) or die "can't see data file"; print FILE "$sid:$lname:$fname:$email:$status:",join(" ",@sections +),"\n"; close FILE; print $q->redirect($thank); }; if ($@) { my $msg = $@; push @err, "There was a server problem. Please contact your GSI." unless @err; print $q->header(-status=>500), $q->start_html('Something Went Wrong'), $q->h2('Something Went Wrong'), $q->ul(map { $q->li($_) } @err ), $q->end_html; die $msg; } __DATA__ <form action="./class-schedule-form.cgi"> SID: <input type="text" name="sid" /></td> <br/> First Name: <input type="text" name="fname" /> <br/> Last Name: <input type="text" name="lname" /> <br/> Email Address: <input type="text" name="email" /> <br/> <p> Enrollment Status: <select name="status"> <option value="none" selected>Pick One</option> <option value="E">Enrolled</option> <option value="W">Waitlisted</option> <option value="N">Neither</option> </select> <br/> <p> Sections Available...<br/> <input type="checkbox" name="section" value="0" /> Mon 10 - 11am<br/> <input type="checkbox" name="section" value="1" /> Mon 2 - 3pm<br/> <input type="checkbox" name="section" value="2" /> Mon 3 - 4pm<br/> <input type="checkbox" name="section" value="3" /> Mon 4 - 5pm<br/> <input type="checkbox" name="section" value="4" /> Tue 12 - 1pm<br/> <input type="checkbox" name="section" value="5" /> Tue 1 - 2pm<br/> <input type="checkbox" name="section" value="6" /> Tue 4 - 5pm<br/> <input type="checkbox" name="section" value="7" /> Wed 9 - 10am<br/> <input type="checkbox" name="section" value="8" /> Wed 10 - 11am<br/> <input type="checkbox" name="section" value="9" /> Thur 12 - 1pm<br/> <input type="checkbox" name="section" value="10" /> Thur 1 - 2pm<br/> <p> <input type="checkbox" name="none" value="1" /> I can't make any of th +ese<br/> <p> <input type="submit" value="Submit"/> </form>

In reply to Discussion Section / Office Hours Poll Taker by hossman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-03-30 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found