<?php
require_once("x64_simple_counter.php");
?> <html> <head> <title>Example3</title> </head> <body> Please give 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(); if(!file_exists("votes.dat")) { $votes = array('foo'=>0,'bar'=>0); } else $votes=unserialize(file_get_contents("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>
|