No database online polls to investigate PHP code this is a php +txt text file made online call voting system, without database support can complete the online user survey function.
Online Survey program code
survey.php
/*
No database Tutorials online poll to investigate PHP code
This is a php +txt text file made by the online call voting system, without database support can complete the online user survey function.
*/
$data = "Data.txt";
$votes = "Survey.txt";
$dataf =file ($data); /* read out the items in the survey project file */
$file _votes=fopen ($votes, "R");
$line _votes=fgets ($file _votes, 255); /* Read the results of the survey already recorded */
Fclose ($file _votes);
$single _vote=explode ("|", $line _votes); /* and cut the data into the specified string, then pass the string back to the array variable */
if ($result!=1)/* If the survey has been accepted */
{
$file _votes=file ($votes, "R");
if ($remote _addr = = $file _votes[1])/* Check is not the same person */
{
echo "
You have voted, thank you for your participation! ";
Exit
}
/* If IP is not duplicated, execute the following program */
$ficdest =fopen ($votes, "w");
for ($i =0; $i <=count ($DATAF)-1; $i + +)
{
if ($i = = $vote)
{/* Determine which item was selected */
$single _vote[$i]+=1;
}
Fputs ($ficdest, "$single _vote[$i]|"); /* Write data back to file */
}
Fputs ($ficdest, "n$remote_addr");/*//write voter ip*/
Fclose ($ficdest);
$result = 1; /* Vote Successful */
}
/* After writing the poll results and displaying the poll results */
if ($result ==1)
{
echo "
"; for ($i =0; $i <=count ($DATAF)-1; $i + +) {/* Get total votes */$tot _votes+= $single _vote[$i]; } for ($i =0; $i <=count ($DATAF)-1; $i + +) {$imag =strval ($i). ". GIF ";/* determine which bar image to use to display statistical results */$STAT [$i]= $single _vote[$i]/$tot _votes*100; /* Calculate percent */$scla = $stat [$i]*5;/* bar and magnification, here is the width of 5 times times the phase of the Ann percentage to display the */echo "
";
echo "$dataf [$i] |
";
echo "";/* Output Barcode graph */
printf ("%.1f", "$stat [$i]");
echo "% |
";
/* Output This column voting number * *
echo "$single _vote[$i]";
echo " |
"; } echo "
";
echo "Total votes: $tot _votes";
}
/*
Data.txt file
Survey Project One
Survey Item Two
Survey Item Three
Survey Item Four
Survey Item Five
*/
?>
http://www.bkjia.com/PHPjc/632061.html www.bkjia.com true http://www.bkjia.com/PHPjc/632061.html techarticle no database online polls to investigate PHP code this is a php +txt text file made online call voting system, without database support can complete the online user survey function. HTML head ...