<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/bootstrap.min.css"/>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

  <title>KVS Digital - VOTING SYSTEM</title>
  <script type = "text/javascript" >
  history.pushState(null, null, 'index.html');
 window.addEventListener('popstate', function(event) {
  history.pushState(null, null, 'index.html');
  });

</script>
</head>
<body>

<div class="container">
<div class="container">
    <nav class="navbar navbar-default">

     <h1>KVS Digital - VOTING SYSTEM</h1>
    <ul class="nav navbar-nav">
      <li class="active"><a href="index.html">Home</a></li>
      <li><a href="login.html">Undian</a></li>
      <li><a href="admin.html">Admin</a></li>
    </ul>

  </nav>

<?php

include 'dbconn.php';
$ic=$_POST["var"];
if (isset($_POST['submit1'])) {
    
$sq = "UPDATE tblstudent SET voteStatus='2' WHERE studentIC='$ic'";
$update = mysqli_query($conn,$sq);

// Loop to store and display values of individual checked checkbox.

$selected = $_POST["check"];


$N = count($selected);
echo "<h4>Calon EXCO MPP (SIJIL) Pilihan anda</h4><br><br>";

for($i=0; $i < $N; $i++)
{
//echo($selected[$i] . " ");
$id = $selected[$i];
 $votecast = "select * from tblcandidate WHERE candID='$id'";
$cast = mysqli_query($conn,$votecast);
$row = mysqli_fetch_assoc($cast);
echo $row[candName];


echo "<br>"; 
$v=$row[voteCount];
        $v = $v + 1;
        $sq1 = "UPDATE tblcandidate SET voteCount='$v' WHERE candID='$id'";
        $qq=mysqli_query($conn, $sq1);

 }   

}   
?>
<br><h4>TERIMA KASIH - UNDIAN ANDA AKAN DIPROSES</h4>
<button type="button" class="btn btn-success"><a href="index.html">KELUAR</a></button>
</div>
</body>
</html>
