No database online polls to investigate PHP code _php instances

Source: Internet
Author: User
Tags string back
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 details are as follows

  <title>Online Survey program code</title>     Survey.php <? /* 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 '
 
  
   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 is selected */$single _vote      [$i]+=1; } fputs ($ficdest, "$single _vote[$i]|");   /* Write data back to file */} fputs ($ficdest, "n$remote_addr");/*/write to voter ip*/fclose ($ficdest); $result = 1; /* Vote successfully */}/* After writing the poll results and display 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 " 
  
  • "; echo "$dataf [$i]
  • "; echo "";/* Output Barcode Graph */printf ("%.1f", "$stat [$i]"); echo "% "; /* Output This column voting number */echo "$single _vote[$i]"; echo "

    "; echo "Total votes: $tot _votes";} /* Data.txt File Survey Project two survey project three investigation project four investigation Project five */?>

    The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support the script home.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.