- Execute these queries on your database:
<?php
# Table structure for table `poll_check`
CREATE TABLE `poll_check` (
`pollid` int(11) NOT NULL default '0',
`ip` varchar(20) NOT NULL default '',
`time` varchar(14) NOT NULL default ''
) TYPE=MyISAM COMMENT='';
# -----------------------------------------
# Table structure for table `poll_data`
CREATE TABLE `poll_data` (
`pollid` int(11) NOT NULL default '0',
`polltext` varchar(50) NOT NULL default '',
`votecount` int(11) NOT NULL default '0',
`voteid` int(11) NOT NULL default '0',
`status` varchar(6) default NULL
) TYPE=MyISAM COMMENT='';
# -----------------------------------------
# Table structure for table `poll_desc`
CREATE TABLE `poll_desc` (
`pollid` int(11) NOT NULL default '0',
`polltitle` varchar(100) NOT NULL default '',
`timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
`votecount` mediumint(9) NOT NULL default '0',
`STATUS` varchar(6) default NULL,
PRIMARY KEY (`pollid`)
) TYPE=MyISAM COMMENT='';
# -----------------------------------------
?>
- Set up database connection parameters. If you don't know
how, check our simple
MySQL database connection tutorial.
- Paste this code on page where you wish poll to appear:
<?php
include_once ("includes/miniPoll.class.php");
$test = new miniPoll;
$test->pollForm();
?>
- 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);
}
?>
- 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();
?>
- Set up these parameters in miniPoll.class.php:
<?php $this->results_page = "test_poll_results.php"; ?>
- page where you display results
- Set up these parameters in miniPollAdmin.class.php:
<?php $this->results_page = "test_poll_admin.php"; ?>
- name of admin page file
- Optionally you can change layout of form and results page
- Create new poll by starting admin page
- Activate your poll by clicking ACTIVATE
- Enjoy and send me your comments