<?php
	$db_name = "sac";
	$table_name = "electSAC";

	$today="";
	$FLName = $_POST['FLName'];
	$authtext = $_POST['authtext'];
	$connection = @mysql_connect("ulibtest1.lang.uc.edu", "matchacl", "1r2rta1rtft")
		or die("Couldn't connect to database server");

	$query= "SELECT * FROM $table_name WHERE (FLName=\"$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['SACvoted'];
    	}
    $auth2 = "yes";
	if ($authtext = $auth and $voted != $auth2) {
	$Voter = $FLName . " authenticated.";
 	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=\"FLName\" value=\"$FLName\"><BR>
	  			<input type=\"hidden\" name=\"auth\" value=\"$auth\"><BR> 
        </p>
        <p>
          <INPUT TYPE=CHECKBOX NAME=\"Borkenhagen\" value=\"Gregory Borkenhagen\">Gregory Borkenhagen<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Burke\" value=\"Jennifer Burke\">Jennifer Burke<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Haitz\" value=\"Lisa Haitz\">Lisa Haitz<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Hiller\" value=\"Karl Hiller\">Karl Hiller<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Korte\" value=\"Matthew Korte\">Matthew Korte<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Manuel\" value=\"Diana Manuel\">Diana Manuel<BR>
          <INPUT TYPE=CHECKBOX NAME=\"Tucker\" value=\"Hyacinth Tucker\">Hyacinth Tucker<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>
  "; 
  }
  else {
	  $Voter = $FLName . " not authenticated.";
    if ($voted = $auth2){
      echo " <h2>You have already voted.  You may not vote twice.</h2>";
    }
    else {
    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 persist, please contact Cherie Matchan at 556-1404.  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); 


?>
