<?php
	$db_name = "systems";
	$table_name = "sacTEST";

	$today="";
	$FLName = $_POST['FLName'];
	$authtext = $_POST['authtext'];
	//echo"$FLName, $authtext";
  $connection = @mysql_connect("libitdb.lang.uc.edu", "phpadmin", "25or624")
		or die("Couldn't connect to database server");
	$query= "SELECT * FROM $table_name WHERE (auth=\"$authtext\" and numkey=\"$FLName\")";

	$db = @mysql_select_db($db_name, $connection)
		or die("Couldn't select database: $db_name");

	$result = @mysql_query($query, $connection)
		or die("Couldn't execute query. <p>$query</p>");

		while ($row = mysql_fetch_array($result)) {
			$auth = $row['auth'];
			$voted = $row['voted'];
			$LName = $row['LName'];
			$FName = $row['FName'];
			$numkey = $row[numkey];
			$blank = " ";
			$votr = $FName.$blank.$LName;
			$FLName = $FName.$blank.$LName;
			//echo"$FLName";
		    	}
    $auth2 = "yes";
	switch($authtext){
     case $auth:
       switch($voted){
         case "blank":
        	$Voter = $FLName . " authenticated." . $authtext . " - " . $auth;
      	 	echo "
      	  <html>
        	<head>
      	  <title>Staff Advisory Committee Ballot</title>
      	  </head>
      	  <body>
      	  <h1 align=\"center\">Thank you for voting.</h1>
      	  <center>
      	  <p>$Voter</p>  
      	  <p></p>  
      	  <p>Select two (2) of the nominees below.  If you select more than two, only the first two, alphabetically sorted, will be counted.</BR>  
      	  <p>You may only vote once.  *****WARNING*****.  The nominees you vote for are not recorded, but the fact that you voted is.</BR>
      		<p>Since the nominees you vote for are not recorded, there is no way to go back and redo your vote.  So, please vote carefully.</p>  
      	  <p>Thank you for participating.</p>  
      	  <FORM METHOD=\"post\" ACTION=\"SACballot.php\">

      	  <TABLE CELLSPACING=\"3\" CELLPADDING=\"3\">
      	    <TR>
      	      <TD height=\"125\" VALIGN=TOP><P><STRONG>Nominee's Last Name:</STRONG><BR>
      	        <p>
      		  			<input type=\"hidden\" name=\"numkey\" value=\"$numkey\"><BR>
      		  			<input type=\"hidden\" name=\"authtext\" value=\"$authtext\"><BR> 
      	        </p>
      	        <p>
      	          <INPUT TYPE=CHECKBOX NAME=\"Early\" value=\"Alphonzo Early\">Alphonzo Early<BR>
      	          <INPUT TYPE=CHECKBOX NAME=\"Manuel\" value=\"Diana Manuel\">Diana Manuel<BR>
      	          <INPUT TYPE=CHECKBOX NAME=\"Hight\" value=\"Susan Hight\">Susan Hight<BR>
      	        </p>
      	        <P>
      	          <INPUT TYPE=\"SUBMIT\" NAME=\"submit\" VALUE=\"Submit Ballot\">
      	        </P></TD>
      	      </TR>
      	      <TR>
      	        <TD width=\"904\" height=\"125\" VALIGN=TOP> <P>&nbsp;
      	          </TD>
      	      </TR>
      	    </TABLE>
      	  
      	  </FORM>
      	
      	  </body>
      	  </html>
      	  "; 

         case "yes":
           echo " <h2>You have already voted.  You may not vote twice.</h2>";
         }
         break;
         default:
    	     $Voter = $FLName . " not authenticated.";
           echo "
            <html>
            <head>
            <title>Staff Advisory Committee Ballot</title>
            </head>
            <body>
            <center>
            <h1 align=\"center\">$Voter - If you reached this screne, you entered a null password.  Please Try Again.</h1>
            <p></p>
            <p>If the problem persists, please contact Thomas Scherz at 556-1406.  Thank You.</p>
            </center>
            </body>
            </html>
            "; 

     case "":
    	  $Voter = $FLName . " not authenticated.";
        echo "
         <html>
         <head>
         <title>Staff Advisory Committee Ballot</title>
         </head>
         <body>
         <center>
         <h1 align=\"center\">$Voter Please Try Again.</h1>
         <p></p>
         <p>If the problem persists, please contact Thomas Scherz at 556-1406.  Thank You.</p>
         </center>
         </body>
         </html>
         "; 
     default:
    	  $Voter = $FLName . " not authenticated.";
        echo "
         <html>
         <head>
         <title>Staff Advisory Committee Ballot</title>
         </head>
         <body>
         <center>
         <h1 align=\"center\">$Voter Please Try Again.</h1>
         <p></p>
         <p>If the problem persists, please contact Thomas Scherz at 556-1406.  Thank You.</p>
         </center>
         </body>
         </html>
         "; 
    }
  

//mail function 
// notify the person responsible
//$mailTo = "shroyecl@ucmail.uc.edu"; 
//$msgSubject = "Library Staff Decanal Review Committee $LName Voted"; 
//$msgBody = $Nominee;
//$xHeaders = "From: Library Staff Decanal Review Committee Nominee Selection Form";

// notify the requestor their help call has been received.
//mail ($mailTo, $msgSubject, $msgBody, $xHeaders); 


?>
