Why doesn't this code work?
<?php
$filen = "C:/wamp/www/uppgifter/saves/speltva.txt";
$s=fopen($filen,'a+');
$f=fopen($filen,'r');
if(isset($_POST['nyttspel'])) {
$result = "--";
$s=fopen($filen,'w');
fwrite ($s, $result);
fclose($s);
} else {
$f=fopen($filen,'r');
$result = fgets($f);
}
if(isset($_POST['sten'])) {
if ($result[0] == "-")
$result[0] == "a";
else
$result[1] == "a";
}
if(isset($_POST['sax'])) {
if ($result[0] == "-")
$result[0] == "b";
else
$result[1] == "b";
}
if(isset($_POST['pase'])) {
if ($result[0] == "-")
$result[0] == "c";
else
$result[1] == "c";
}
fclose($f);
$s=fopen($filen,'w');
fwrite ($s, $result);
echo $result;
?>
<form method=post action=stensax.php>
<center>
<input type='submit' name=nyttspel value=NYTT SPEL>
<input type='submit' name=sten value=STEN>
<input type='submit' name=sax value=SAX>
<input type='submit' name=pase value=PÅSE>
</center>
I want it to put "--" in the file first as a gameboard. When someone selects "sten" (rock) it should change the first "-" into an "a" if it's empty, otherwise change the second "-" to an "a". When I press "nyttspel" (new game), it fills the .txt file with an empty gameboard, like it should, but nothing happens when I press any of the other buttons. Why is that?