I finished my survey and its working fine but I have a problem with survey results page. What I need is to show all results each time some one takes the survey and saves it to a text file. Right now it just adds 1 to each question taken and overwrites the previous. Also I want each selection on diffrent lines. I want it to show what each person selects that takes the survey. Here is the survey link and the code for the php file. Hope someone can help.
http://student.cse.fau.edu/cop3813/vvalente/websurvey
<?php
if(@$_COOKIE['websurvey'])
{
die("<br/>You will be able to return in 24 hours");
}
else
{
extract($_POST);
setcookie("websurvey",$username,time()+86400);
setcookie("time",time()+86400);
}
?>
<html>
<head>
<title>Web survey PHP file</title>
</head
<?php
extract($_POST);
$fptr=fopen("data.txt","r+b");
$line=fgets($fptr);
$answer = split(",",$line,10);
if($q0 =="yes")
{
$answer[0]+=1;
}
elseif($q0=="No")
{
$answer[0]-=1;
}
else
;
if($q1=="yes")
{
$answer[1]+=1;
}
elseif($q1 =="no")
{
$answer[1]-=1;
}
else
;
if($q2=="yes")
{
$answer[2]+=1;
}
elseif($q2 =="no")
{
$answer[2]-=1;
}
else
;
if($q3=="yes")
{
$answer[3]+=1;
}
elseif($q3 =="no")
{
$answer[3]-=1;
}
else
;
if($q4=="yes")
{
$answer[4]+=1;
}
elseif($q4 =="no")
{
$answer[4]-=1;
}
else
;
if($q5=="yes")
{
$answer[5]+=1;
}
elseif($q5 =="no")
{
$answer[5]-=1;
}
else
;
if($q6=="yes")
{
$answer[6]+=1;
}
elseif($q6 =="no")
{
$answer[6]-=1;
}
else
;
if($q7=="yes")
{
$answer[7]+=1;
}
elseif($q7 =="no")
{
$answer[7]-=1;
}
else
;
if($q8=="yes")
{
$answer[8]+=1;
}
elseif($q8 =="no")
{
$answer[8]-=1;
}
else
;
if($q9=="yes")
{
$answer[9]+=1;
}
elseif($q9 =="no")
{
$answer[9]-=1;
}
else
;
rewind($fptr);
$line=join(",",$answer);
fwrite($fptr,$line);
fclose($fptr);
print("<h3>Survey results;$line<h3>");
?>
</body>
</html>