Clarkson Computer Sales & Service Center Freshman Sales
The following code, order.cgi, is the program that processes the order
when a student submits the form and writes the information to the database
file, order.txt.
#!/usr/local/bin/perl
#
# bring_buy.cgi
# This Program Copyright (c) Gregory J. Borrelli 2000
# You may not use any part of this program without permission
# greg@borrellinet.net
&read_form_results;
open (OUT, ">>admin/order.txt");
print (OUT
"$entry{last_name}:$entry{first_name}:$entry{middle_initial}:
$entry{student_number}:$entry{email_address}:$entry{address}:
$entry{city}:$entry{state}:$entry{zip_code}:$entry{zip_code_ext}:
$entry{area_code}:$entry{local_code}:$entry{local_number}:
$entry{Buy_Dell_Computer}:$entry{Buy_HP_Printer}\n");
&success;
sub success{
print ("Location:thanks.html\n\n");
}
sub read_form_results {
local ($buffer, $name, $value);
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach (split(/&/, $buffer))
{
($name, $value) = split(/=/);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$entry{$name} = $value;
}
1;
}
The following code, view_order.cgi, is the program that processes the information
when a user makes a request to view the orders that have been submited. Then,
depending on the options that the user has selected, it dynamically generates a page
that shows the information to the user that it gets from the database file, order.txt