vote_count.php

48 istruzioni
<?php
$lang="en";
include "../head_include.php";
include "config.php";
include "index_include.php";
$id = $_REQUEST['id'];
if ($id < 0 || $id > count($candidate_nam)) {
    echo "Call Police!";
    exit;
}

/* place here the command to write on the ballot paper
   the word "VERIFIED by voter" and then
   cut the roll paper or eject the ballot paper into the ballotbox
*/
$filename = $counters_path ."counter_of_id=$id.txt";
$handle = fopen($filename, 'r');
$votes = fread($handle, 100);
fclose($handle);
echo "<center>";
echo "<br/>votes of $candidate_nam[$id] were $votes  (in real voting this print will not exist)";
$votes = $votes + 1;
echo "<br/>votes of $candidate_nam[$id] are now $votes (in real voting this print will not exist)";
$handle = fopen($filename, 'w');
fwrite($handle, $votes, 100);
fclose($handle);
unlink($lockfile);
// header ('Location: index.php');
?>
<form method="POST" action="index.php">
in real voting, soon after having verified your ballot paper you would have gone back to the first page of voting
<br/>(that it would be inaccessible since you have already voted). <p>Since this is a test
please click the next button to go to the first page (that is even accessible!)</p>
<p><input id="confirm" type="submit" value="go to first page"/></p>
</form>
</center>
<?
   if (file_exists("$_SERVER[DOCUMENT_ROOT]/CONTAMI/phpcounter.php")) {
        echo '<br/><div id="contatore" class="centro piccolone">', "\n";
        require "$_SERVER[DOCUMENT_ROOT]/CONTAMI/phpcounter.php";
        echo "</div>\n";
    }
?>
</body>
</html>