$stem = $_POST["stem"];
$ip=$_SERVER['REMOTE_ADDR'];
$words = file ("ip.txt", "r") or exit("Unable to open file!");
$agenda = "ip.txt";
foreach ($words as $line_num => $word)
{
$links=substr ($word,1,10);
if ($links == $ip) {echo 'Jij hebt al gestemd! je mag maar een keer stemmen!';}
elseif($stem == "p"){
$f=fopen("ip.txt","a");
fwrite($f," $ip");
fclose($f);
$fp=fopen("p.txt","r");
$get=fgets($fp,255);
fclose($fp);
$fw=fopen("p.txt","w");
$temp=$get+1;
$put=fputs($fw,$get+1);
echo "bedankt voor het stemmen:<br /><B>" .$temp." </B> mensen hadden ook net als jouw ook deze mening";
echo "<br/>professioneel:  ";
include('p.txt');
echo "<br />gemiddeld:  ";
include('g.txt');
echo "<br />amateuristisch:  ";
include('a.txt');
fclose($fw);
}
elseif($stem == "g"){
$f=fopen("ip.txt","a");
fwrite($f," $ip");
fclose($f);
$fp=fopen("g.txt","r");
$get=fgets($fp,255);
fclose($fp);
$fw=fopen("g.txt","w");
$temp=$get+1;
$put=fputs($fw,$get+1);
echo "bedankt voor het stemmen:<br /><B>" .$temp." </B> hadden ook die mening";
echo "<br/>professioneel:  ";
include('p.txt');
echo "<br />gemiddeld:  ";
include('g.txt');
echo "<br />amateuristisch:  ";
include('a.txt');
fclose($fw);
}
elseif($stem == "a"){
$f=fopen("ip.txt","a");
fwrite($f," $ip");
fclose($f);
$fp=fopen("a.txt","r");
$get=fgets($fp,255);
fclose($fp);
$fw=fopen("a.txt","w");
$temp=$get+1;
$put=fputs($fw,$get+1);
echo "NOU BEDANKT.....<B>" .$temp." </B> hadden ook die STOMME MENIG mening";
echo "<br/>professioneel:  ";
include('p.txt');
echo "<br />gemiddeld:  ";
include('g.txt');
echo "<br />amateuristisch:  ";
include('a.txt');
fclose($fw);
}
?>