Free PHP Scripts, SEO tools and tutorials - Sim.PHP


Scripts.com

Simple Mini Poll class library (SimPoll)

Download: Demo:

http://www.free-midi.org

Price:

Free. If you like this script, please view my small Amazon Wish List. I will also give free tech support to those who donate :)

Description:

This easy-to-use class library enables you to set up your own survey system in just few minutes.

Main features include:
  • Dynamically generated form (with number of total votes)
  • Detailed result page
  • View of old polls
  • Poll administration interface
  • Check for repeated votes
Version history:
  • v1.1 July 28, 2005
  • v1.0 January 9, 2004
Requirements:
  • PHP
  • MySQL
Installation:
  1. Execute these queries on your database:

  2. <?php
    # Table structure for table `poll_check`

    CREATE TABLE `poll_check` (
      `
    pollidint(11NOT NULL default '0',
      `
    ipvarchar(20NOT NULL default '',
      `
    timevarchar(14NOT NULL default ''
    TYPE=MyISAM COMMENT='';

    # -----------------------------------------

    # Table structure for table `poll_data`

    CREATE TABLE `poll_data` (
      `
    pollidint(11NOT NULL default '0',
      `
    polltextvarchar(50NOT NULL default '',
      `
    votecountint(11NOT NULL default '0',
      `
    voteidint(11NOT NULL default '0',
      `
    statusvarchar(6) default NULL
    TYPE=MyISAM COMMENT='';

    # -----------------------------------------

    # Table structure for table `poll_desc`

    CREATE TABLE `poll_desc` (
      `
    pollidint(11NOT NULL default '0',
      `
    polltitlevarchar(100NOT NULL default '',
      `
    timestampdatetime NOT NULL default '0000-00-00 00:00:00',
      `
    votecountmediumint(9NOT NULL default '0',
      `
    STATUSvarchar(6) default NULL,
      
    PRIMARY KEY (`pollid`)
    TYPE=MyISAM COMMENT='';

    # -----------------------------------------
    ?>
                          

  3. Set up database connection parameters. If you don't know how, check our simple MySQL database connection tutorial.


  4. Paste this code on page where you wish poll to appear:


  5. <?php

    include_once ("includes/miniPoll.class.php");

    $test = new miniPoll;

    $test->pollForm();

    ?>
                          

  6. Paste this code on page where you wish poll results to appear:

    <?php

    include_once ("includes/miniPoll.class.php");

    $test = new miniPoll;

    if (isset(
    $_GET['poll']) && is_numeric($_GET['pollid'])) {
        
    $pollid $_GET['pollid'];

        if (isset(
    $_GET['voteid']) && is_numeric($_GET['voteid'])) {
            
    $voteid $_GET['voteid'];
            
    $test->processPoll($pollid$voteid);
        }

    }
    if (isset(
    $_GET['pollid'])) {
        
    $pollid $_GET['pollid'];
        
    $test->pollResults($pollid);
    }

    ?>
                            

  7. Paste this code on poll admin page:

    <?php

    include_once ("includes/miniPollAdmin.class.php");

    $test = new miniPollAdmin;

    $test->newPollForm();

    if (isset(
    $_GET['opt'])) {
        
    $opt $_GET['opt'];
        
    $pollid $_GET['pollid'];
        if (
    $opt == 'activate') {
            
    $test->activatePoll($pollid);
        }
        if (
    $opt == 'delete') {
            
    $test->deletePoll($pollid);
        }

    }

    echo 
    "<br />";
    if (isset(
    $_GET['q'])) {
        
    $pollname $_GET['pollname'];
        
    $q $_GET['q'];
        
    $test->createPoll($pollname$q);
    }
    $test->listPolls();

    ?>
                            

  8. Set up these parameters in miniPoll.class.php:

    <?php $this->results_page "test_poll_results.php"?>
                            
    - page where you display results

  9. Set up these parameters in miniPollAdmin.class.php:

    <?php $this->results_page "test_poll_admin.php"?>
                            
    - name of admin page file

  10. Optionally you can change layout of form and results page
  11. Create new poll by starting admin page
  12. Activate your poll by clicking ACTIVATE
  13. Enjoy and send me your comments

 
Sim.PHP © 2004 - Free PHP Scripts, SEO tools and tutorials | Privacy policy