index.php :
<?php
$variants=file("variants.txt");
$current_var=0;
$results=file("results.txt");
$current_res=1;
$itog=0;
echo "<form action=add_golos.php method=post>";
echo "<b>$variants[$current_var].</b><br>";
$current_var++;
echo "<table>";
While (count($variants)!=$current_var)
{
echo "<tr>";
echo "<td>$variants[$current_var].<td><input type=radio name=first value='$current_var'>";
echo "<td>(voters: $results[$current_var] users.)";
$itog=$itog+$results[$current_var];
$current_var++;
$current_res++;
}
echo "</table>";
echo "<br><input type=submit name=golos value=votenow>";
echo "<br>All voters: $itog users";
echo "</form>"
?>
add_golos.php:
<?php
if (isset($_POST['golos']))
{
if (isset($_POST['first']))
{
$f=fopen("results.txt","r+b") or die("Error");
flock($f,2);
$stroka=fgets($f);
$i=0;
While($_POST['first']!=$i)
{
$position=ftell($f);
$stroka=fgets($f);
$i++;
}
fseek($f,$position,SEEK_SET);
$new_value=$stroka+1;
fputs($f,$new_value);
flock($f,3);
fclose($f);
}
}
header("location:index.php");
?>
Where its code running current, its writing only '1', and reading nothing. I spent a lot of time studying this code, but could not find any errors Its look as no errors. Who can explained to what was going on
Aucun commentaire:
Enregistrer un commentaire