Location: PHPKode > scripts > x64 Simple Counter > x64-simple-counter/example3.php
<?php

require_once("x64_simple_counter.php");

?>
<html>
<head>
<title>Example3</title>
</head>
<body>
Please tell us your opinion:<br/>
<form action="example3.php" method="post">
Foo <input type="radio" name="option" value="foo"><br/>
Bar <input type="radio" name="option" value="bar"><br/>
<input type="submit">
</form>
<?php

if(isset($_POST["option"]))
{
	echo "<hr/>\n";
	$counter=new x64_simple_counter('example3_counter_data.php',0);
	if(!$counter->already_counted())
	{
		$counter->auto();
		$votes=unserialize(file("votes.dat"));
		if($_POST["option"]=="foo"||$_POST["option"]=="bar")
		{
			$continue=true;
			$votes[$_POST["option"]]++;
		}
		else
		{
			$continue=false;
			echo "Don't try to hack us! now, don't think that you can still vote anymore!<br/>";
		}
		if($continue)
		{
			$fp=fopen("votes.dat","wb");
			fwrite($fp,serialize($votes));
			fclose($fp);
			echo "Thanks for voting.<br/>";
		}
	}
	else
	{
		?>Sorry, but you already voted.<?php
	}
}

?>
</body>
</html>
Return current item: x64 Simple Counter