No database 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.
The HTML code is as follows:
The survey.php code is as follows:
<? /* No Database Tutorials online poll for PHP code this is a php +txt text file made 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 out the recorded findings */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 you have already accepted the investigation */{$file _votes=file ($votes, "R"); if ($remote _addr = = $file _votes[1])/* Check is not the same person */{echo ' <center><font Color=red> you have voted, thank you for your participation! </font></center> "; 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 successfully */}/* After writing the poll results and display the poll results */if ($result ==1) {echo "<table cellpadding=10>"; 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 "<tr><td><li><font FAC E=verdana size=2> "; echo "$dataf [$i]</font></td><td align=left><font face=verdana size=2>"; echo " "; * Output Barcode Map */printf ("%.1f", "$stat [$i]"); echo "%</font></td><td Align=center><font face=verdana size=2>"; /* Output This column voting number */echo "$single _vote[$i]</font>"; echo "</td></tr>"; } echo "</table><p>"; echo "<font Face=verdana size=2> Total votes: $tot _votes </font>"; }/* Data.txt File Survey Project two survey project three investigation project four investigation Project five */?>
Source: Summer Blog
PHP Online Survey program code-TripAdvisor Blog