#!usr/local/bin/perl;
package studentdata;
use lib 'c:\Netscape\Server\ourlib';
use CGI ("shortcuts");
use CGI::Carp qw(fatalsToBrowser);
$query=new CGI;
#Use the ODBC module
use Win32::ODBC;
#our dsn
use ISLib;
my $DSN='DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\\\\140.247.216.106\\inetpub\\wwwroot\\is\\database\\hls_is_981.Mdb';
print $query->header();
my $ISobj= new ISLib('Edit Student Profile');

print $ISobj->pagetop();
#open a connection to it
my $O = new Win32::ODBC($DSN) || die "Unable to open DSN $DSN\n";
##The page is called by StudentID or "new"
##Grab any existing data
my %sdata;
%sdata=();
if ($query->param('StudentID') eq "") {
	$StudentID = "new"; 
	$sdata{'FirstName'}=$query->param('FirstName');
	$sdata{'LastName'}=$query->param('LastName');
} else { 
	$StudentID = $query->param('StudentID');
	if (! $O->Sql("SELECT * 
		FROM Students
		WHERE StudentID = $StudentID ")) {
	( $O->FetchRow() ) ||  print $O->DumpError(), "\n";
	%sdata = $O->DataHash();
		}
}
$O->Close();

print qq[
  <FORM METHOD = "post" ACTION = "addstudent.cgi">
  <P>];
# print "Student ID:",$query->param('StudentID');
unless ($StudentID eq "new"){ print qq! 
	<table width="500" cellspacing="0" cellpadding="0">
	<tr><td colspan="2"><font size="+1">Name: $sdata{'FirstReal'} $sdata{'LastReal'}</font></td></tr>\n 
	<input type="hidden" name="FirstReal" value="$sdata{'FirstReal'}">\n
	<input type="hidden" name="LastReal" value="$sdata{'LastReal'}">\n
	!;
	} else { print qq! 
	<table width="500" cellspacing="0" cellpadding="0">
	<tr><td width="150">First Name:</td><td width="350"> <input type="text" name="FirstReal" size="15"></td></tr>\n
			<td>Last Name:</td><td>  <input type="text" name="LastReal" size="15"></td></tr>!
	}
print qq!
<tr><td width="150">Email:</td><td width="350"> <input type="text" name="EmailName" value="$sdata{'EmailName'}" size="20"> \n</td></tr>
<tr><td>Affiliation (year):</td><td> <input type="text" name="Affiliation" value="$sdata{'Affiliation'}" size="20"> \n</td></tr>
<tr><td>Telephone number:</td><td> <input type="text" name="PhoneNumber" value="$sdata{'PhoneNumber'}" size="20"></td></tr>\n
<tr><td>Hometown:</td><td> <INPUT type="text" name="Hometown" value="$sdata{Hometown}" size="20"></td></tr>\n
<tr><td>Favorite website (URL):</td><td> <input type="text" name="Website" value="$sdata{'FavoriteWeb'}" size="30"></td></tr>\n
<tr><td>Internet-related research interests:</td><td> <INPUT type="text" name="Research" value="$sdata{Research}" size="30"></td></tr>\n
<tr><td>Favorite book:</td><td> <INPUT type="text" name="FavoriteBook" value="$sdata{FavoriteBook}" size="30"></td></tr>\n
<tr><td>Fun facts about you:</td><td> <TEXTAREA name="FunFacts" rows="4" cols="50" wrap="virtual">$sdata{FunFacts}</TEXTAREA></td></tr>\n
<tr><td>Password:</td><td> <input type="password" name="Password" size="20"></td></tr>\n
<tr><td>Enter password again:</td><td> <input type="password" name="Password2" size="20"></td></tr>\n
<tr><td colspan="2">&nbsp;<p>Note: Your profile will not appear in the class list immediately.<p>
<CENTER><INPUT TYPE = "submit" value="Submit Data"> &nbsp; &nbsp; <INPUT TYPE = "reset"></CENTER></td></tr>
<tr><td colspan="2"><br>&nbsp;<p>Check this box to specify a nickname to be used in place of your real name: <input type="checkbox" name="Alias" value="alias"></td></tr>
<tr><td colspan="2">Public first name: <input type="text" name="FirstName" size="13" value="$sdata{'FirstName'}"> &nbsp;
 Public last name: <input type="text" name="LastName" size="13" value="$sdata{'LastName'}"></td></tr>\n 

</TABLE>
!;
print qq!
  <input type="hidden" name="StudentID" value="$StudentID">\n
    </FORM> 
!;

#<p>Your profile will be displayed on a student list visible to all members of the class. 
#Class pages may also be made available to the interested public.  If you like, you may enter a pseudonym
#for your "public name," to be listed with your profile and comments on the website. \n
#You must also enter your real name here for administrative and grading purposes.\n
#Please consider using your real name publicly, so that you will be able to continue your 
#classroom conversations online, and vice versa.\n
#To ensure continuity of the online discussions, you will not be able to modify your public name, 
#though you will be able to edit other elements of your profile. <p>

print $ISobj->pagebottom;



