#!/usr/local/bin/perl
#searchpartic.pl
#copyright CSNET written by Brian Maguire 


# Define the location of the database
$DATABASE="/export/home/www/mirroreddns/secure/partnerdata.list";

# Define the path to cgiparse
$CGIPATH="/export/home/httpd/cgi-bin/";
# Convert form data to variables
eval `$CGIPATH/test/cgiparse -form -prefix $`;

# Determine the age of the database
$mod_date=int(-M $DATABASE);	

#Display the age of the database and generate the search form
print <<EOM;
Content-type: text/html

<HEAD>
<TITLE> Search for a Partner</TITLE>
</HEAD>
<BODY bgcolor="ffffff">
<CENTER><H3>Welcome to Mind's Eye Monster Exchange Project Partner Chooser</H3></CENTER>
<P>
<hr>
<CENTER><STRONG><H4>Please Fill Out the Form Accurately and Completely. </H4></STRONG></CENTER>


<FORM METHOD = "POST" ACTION = "/cgi-bin/partner.pl">
<HR>What is your grade level?

<INPUT TYPE="radio" NAME="grade_level" VALUE="K">K
<INPUT TYPE="radio" NAME="grade_level" VALUE="1">1
<INPUT TYPE="radio" NAME="grade_level" VALUE="2">2
<INPUT TYPE="radio" NAME="grade_level" VALUE="3">3
<INPUT TYPE="radio" NAME="grade_level" VALUE="4">4
<INPUT TYPE="radio" NAME="grade_level" VALUE="5">5
<INPUT TYPE="radio" NAME="grade_level" VALUE="6">6

<HR>How many students do you have in your class?
<SELECT NAME="student_number">
<OPTION>Student Number
<OPTION>1-5
<OPTION>6-10
<OPTION>11-15
<OPTION>16-20
<OPTION>21-25
<OPTION>26-30
<OPTION>31-35
</SELECT>

<HR>What country are you from?
<SELECT NAME="country">
<OPTION>Country
<OPTION>USA
<OPTION>Spain
<OPTION>Italy
<OPTION>Russia
<OPTION>Japan
</SELECT>
<HR>
<HR>What country are you from?
<SELECT NAME="language">
<OPTION>Your Language
<OPTION>English
<OPTION>French
<OPTION>German
<OPTION>Spanish
<OPTION>Russian
<OPTION>Japanese
</SELECT>
<p>

<INPUT TYPE="submit" VALUE="Submit">
<INPUT TYPE="reset" VALUE="Clear">

EOM

@query = ($grade_level,$student_number,$country,$language);

# Do the search only if a query was entered
if (length($query)>0) {	
  print <<EOM;
Search for <B>$query</B> yields these entries:
<PRE>
EOM

#Inform user if search is unsuccessful
$answer = `grep -i @query $DATABASE`;
if (!$answer) { print "Search was unsuccessful\n" ;}
else { print $answer\n" ; }

print <<EOM;
</PRE>
</BODY>
EOM
}
