#!/usr/bin/perl
use DBI;
undef %f;
&parse_form_data( *f );
require "table.pl";
$id = $f{'id'};
$already_taken = 0;
$dbh = DBI->connect( $database, $dbuser, $dbpass );
$cursor = $dbh->prepare( "SELECT * FROM $table WHERE num_id=$id" );
$cursor->execute;
while ( @field = $cursor->fetchrow ) {
if ( $field[$sponsoridx] == 1 ) {
$already_taken = 1;
last;
}
$sizes = "";
if ( $field[$shirtsizeidx] ne "" ) {
$sizes .= "Shirt size: $field[$shirtsizeidx]
";
}
if ( $field[$pantsizeidx] ne "" ) {
$sizes .= "Pant size: $field[$pantsizeidx]
";
}
if ( $field[$shoesizeidx] ne "" ) {
$sizes .= "Shoe size: $field[$shoesizeidx]
";
}
$wishes = "";
if ( $field[$wish1idx] ne "" ) {
$wishes .= "1. $field[$wish1idx]
";
}
if ( $field[$wish2idx] ne "" ) {
$wishes .= "2. $field[$wish2idx]
";
}
if ( $field[$wish3idx] ne "" ) {
$wishes .= "3. $field[$wish3idx]
";
}
$needs = "";
if ( $field[$need1idx] ne "" ) {
$needs .= "1. $field[$need1idx]
";
}
if ( $field[$need2idx] ne "" ) {
$needs .= "2. $field[$need2idx]
";
}
if ( $field[$need3idx] ne "" ) {
$needs .= "3. $field[$need3idx]
";
}
$faves = "";
if ( $field[$favecoloridx] ne "" ) {
$faves .= "Color: $field[$favecoloridx]
";
}
if ( $field[$favebookidx] ne "" ) {
$faves .= "Book: $field[$favebookidx]
";
}
if ( $field[$favesportidx] ne "" ) {
$faves .= "Sport: $field[$favesportidx]
";
}
if ( $field[$funidx] ne "" ) {
$faves .= "For Fun: $field[$funidx]
";
}
$row = qq |
First Name | Grade | Age | Gender | Size(s) | When I Grow Up I Want to Be... | Wish(es) | Need(s) | Favorites |
---|
Thank you for your interest in sponsoring a student! Please complete all fields below to complete the sponsorship process. Once you hit the "sponsor a child" button, you will receive a confirmation notification both on screen and via email and your student will no longer be available. If you have any questions, please contact Little Match Girl with any questions.
|; sub parse_form_data { local( *FORM_DATA ) = @_; local( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value ); $request_method = $ENV{'REQUEST_METHOD'}; if ( $request_method eq "GET" ) { $query_string = $ENV{'QUERY_STRING'}; } elsif ( $request_method eq "POST" ) { read( STDIN, $query_string, $ENV{'CONTENT_LENGTH'} ); } else { &return_error( 500, "Server Error", "Server uses unsupported method" ); } @key_value_pairs = split( /&/, $query_string ); foreach $key_value ( @key_value_pairs ) { ( $key, $value ) = split( /=/, $key_value ); $value =~ tr/+/ /; $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if ( defined($FORM_DATA{$key}) ) { $FORM_DATA{$key} = join( ", ", $FORM_DATA{$key}, $value ); } else { $FORM_DATA{$key} = $value; } } } sub return_error { local( $status, $keyword, $message ) = @_; print "Content-type: text/html", "\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print <