Can't get my poll script to work.
Can someone please tell me why the APPLES ($voteData[0]) selection never adds new votes.
This is the php file.
<html>
<body>
<form name="survey" method="POST" action="<? echo $_SERVER['PHP_SELF'] ?>">
<b>Select your favorite</b><br>
<label><input type="radio" name="sel" value="0">Apples</label><br>
<label><input type="radio" name="sel" value="1">Oranges</label><br>
<label><input type="radio" name="sel" value="2">Both</label><br>
<input type="submit" name="Survey" value="Vote">
</form>
<?
if(!empty($_POST['sel']))
{
include "dataTxt.txt";
$hndl = fopen("dataTxt.txt", "w+");
fputs($hndl, "<?\n");
if($POST['sel'] == 0)
{
$plusOne = $voteData[0] + 1;
fputs($hndl, "\$voteData[0] = \"$plusOne\";\n");
}
else
{
fputs($hndl, "\$voteData[0] = \"$voteData[0]\";\n");
}
if($POST['sel'] == 1)
{
$plusOne = $voteData[1] + 1;
fputs($hndl, "\$voteData[1] = \"$plusOne\";\n");
}
else
{
fputs($hndl, "\$voteData[1] = \"$voteData[1]\";\n");
}
if($_POST['sel'] == 2)
{
$plusOne = $voteData[2] + 1;
fputs($hndl, "\$voteData[2] = \"$plusOne\";\n");
}
else
{
fputs($hndl, "\$voteData[2] = \"$voteData[2]\";\n");
}
fputs($hndl, "?>");
fclose($hndl);
}
?>
<b>Results</b><br>
<?
include("dataTxt.txt");
echo "Apples (" . $voteData[0] . ")<br>";
echo "Oranges (" . $voteData[1] . ")<br>";
echo "Both (" . $voteData[2] . ")<br>";
?>
</body>
</html>
This is the text file.
<?
$voteData[0] = "0";
$voteData[1] = "0";
$voteData[2] = "0";
?>