#!/usr/local/bin/perl -w
use CGI qw(:standard);

#both left or right ajustiment, when length is 0, will print the string
#put extra :: at the end of .def file to avoid 
# to print out last field as trash


$q = new CGI;
open(def_file,"/z/p/l/plee1274/jws/cgi-bin/bid.def") || print "die<p>";

@lines = <def_file>;
@colnames = split(":",$lines[0]);

my (@ss,$line);

foreach $k (@colnames){
 $v = $q->param("$k");
 if (($k eq "bid") && ($v eq "")){
   system ("perl /z/p/l/plee1274/jws/cgi-bin/getbid.pl \'Some important fields were not filled, please fill the form again\'");
   exit(0);
 }
 if ($v eq "") {
   $v = "null";
 }
 if ($k eq "Date") {
   $v =mydate();
 }
$v="$v:";
push(@ss,$v);
#print "<p>$v\n";
#print "<p>$line\n";
}
pop(@ss); pop(@ss); #get rid of two extra null
foreach (@ss){
# print "$_";
$line="$line$_";

}
#print ("<p>\n");

$line="$line:\n"; #give an extra : and a new line
open(FILE, ">>/z/p/l/plee1274/jws/cgi-bin/bid.dat");
print FILE $line;

print header(), start_html("Thank You For Your Registration"), h1("Thank You For Your Registration");
print "<p> Thank you for registed as following:\n";
print "<p> ------------------------------------\n";
print "<p> $line\n";
close(FILE); # done the append a record/line

print '<p><A HREF="http://grex.org:10000">Home</A>';

#mydate-- change : to + in date format
sub mydate {
  $s = `date`;
  chomp($s);
  my @ss= split(/:/, $s);
  my $ss = join("+", @ss);
  return $ss;
}
