PHP Classes

AJAXPoll: Display polls and update results using AJAX

Recommend this page to a friend!
  Info   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum (4)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 55%Total: 1,973 All time: 1,984 This week: 200Up
Version License PHP version Categories
ajax-poll 1.0GNU General Publi...5.0PHP 5, Content management, AJAX
Description Author

This class can be used to display poll questions and collect the results using AJAX to avoid page reloading.

It can take as parameters a poll question and the HTML to display for each of the poll answers.

The class generates the necessary HTML and Javascript to display the poll on a Web page and submit the answer that the user picks to the server using AJAX.

The class can can also display poll results as graphical bars that represent the percentage of each of the picked poll responses.

The class avoids counting votes from the same user based on the user machine IP address and session variables. It also uses server side text files to store the updated poll results.

Picture of José Augusto Ferreira Franco
  Performance   Level  
Name: José Augusto Ferreira ... <contact>
Classes: 15 packages by
Country: Portugal Portugal
Age: 45
All time rank: 963 in Portugal Portugal
Week rank: 53 Up2 in Portugal Portugal Up
Innovation award
Innovation award
Nominee: 1x

 ---- About this class  -----

  This class is used on the WebExp Template Engine
  WebExp is Template Engine identical to Smarty, created 
  by José Franco and Revista PHP contibutors at 
        >>>     <<<<
  We build this tool to develop PHP Ajax based Web sites fast and easy 
  This project is growing based on contibutors help and users feedback
  If you want to start deploy with us m your can contact us and we will
  send to you our Template Engine PHP source code 
  We proudly present our list of contibutors and supporters
  José Augusto Ferreira Franco (Portugal)
  Informatics Engineer student 
  > WebExp Template Engine Project Manager
    PHP-Ajax Pluggins | Database  Wrapper
  Marcelo Soares da Costa (Brazil)
  FreeBSD System Engineer 
  > WebExp Object Framework developer
  Gabi Solomon (Romania)
  Economical Engineer/PHP programmer
  > WebExp Template Engine features
  Bruno Canongia (Brazil)
  Software Engenineer
  > WebExp PHP-Ajax Api developer
    >>>>>  About this package  
    >>>>>  Author  : José Augusto F. Franco
	>>>>>  Email   :
	>>>>>  Msn     :
	>>>>>  Web     : 
	>>>>>  Package : WebExpPoll test script - Easy way to build your polls with Ajax
    >>>>>  License : GPL

 --------- HOW TO RUN THE SCRIPT ------------------

 1st step -  Uncompress the files on package and add them on your web server httpdocs or www folder.
 2nd step -  Create a new  folder and name it as 'images'. Right next copy all images to there.
 Further steps : 

  Edit the class add add you own configuration

  Inside the class you will find this attributes

  // this is poll question
  public $q =  "What´s your favourite color ? ";
  // Ajax callback (it´s  the name of Ajax function)
  public $f = 'Vote';  (you don´t need to change it)
  // quiz options
  public $opt;
  // quiz name on radios and ajax div name
  public $quiz = 'vote';
  // page to output poll results
  public $output = 'results.php';
    //images location folder
  public $imgRoot = 'images/';
  // js location folder
  public $jsLocation = '';
  // js file
  public $jsFile = 'poll.js';
  // file where votes are saved
  public $pool_db = 'pool_results.txt';
  // graph images background 
  public $graph_bg = 1; // 1 - to random bg   0 - to static bg
  // the image graph  height
  public  $graph_height = '5';
  // message if user cast poll twice
  public $voteRep = "&nbsp;&nbsp; You already cast this poll !";
  // message result
  public $msgRes  = "<h2>Poll results:</h2>";
  //allow to show table again
  public $showT = 'Show poll';
  // the bg color to options table
  public $TableOptColor = '#ccc';
  // style fonts at options table
  public $TableOptStyle = 'mycssClass';

   --------   How to build the class parameters ---------

   To build your own polls edit the file test_poll.php
   and yout poll question on the vatiable $YourPollQuestion
  // your poll question 
  $YourPollQuestion = "Type here your poll question !";


  // set your array option like this
  $yourArrayPollOptions = array("<li>Option one</li>",
                                "<li>Option two</li>",
                                "<li>Option three</li>");

  ---------- Make the class instance (build the poll object) ------

    // creates your PHP-AJAX Poll
   new WebExpPoll($YourPollQuestion,$yourArrayPollOptions);
   -------   About the author -----------

   José Franco is a Informatics Engineer student and he owns his own buisness in Guarda - Portugal
   He´s also the project admin of Portuguese PHP Magazine on a digital version 	identical as PHPMag
   Contact :
   Mobile  :  +351 96 269 44 32
   MSN     :
   Web     :

  Files folder image Files  
File Role Description
Plain text file WebExpPoll.class.php Class PHP Ajax main class
Accessible without login Image file halt.png Icon images from the script
Accessible without login Plain text file Linux_users_help.txt Doc. Run this class on Linux
Accessible without login Image file poll.gif Icon images from the script
Accessible without login Image file poll_black.gif Icon images from the script
Accessible without login Image file poll_green.gif Icon images from the script
Accessible without login Image file poll_orange.gif Icon images from the script
Accessible without login Image file poll_preview.gif Icon Class design preview
Accessible without login Image file poll_purple.gif Icon images from the script
Accessible without login Image file poll_red.gif Icon images from the script
Accessible without login Plain text file readme.txt Data Read me first
Accessible without login Plain text file test_poll.php Example poll test file

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:1,984
This week:200Up
User Ratings User Comments (3)
 All time
14 years ago (vanessa villanueva)
To this class work in every subdirectories, you must change: ...
14 years ago (Nicolas Muller)
Finaly one portuguese contributing with classes .
14 years ago (José Filipe Lopes Santos)
For more information send a message to info at phpclasses dot org.