UP PREVIOUS NEXT   Technologies Internet et Education, © TECFA
  3. Exemple d'installation / utilisation de la classe MiniPoll

3. Exemple d'installation / utilisation de la classe MiniPoll

Exemple 3-1: Demo de MiniPoll à TECFA

3.1 Installation des tables MySQL

 
 
 
 
# 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='';

3.2 Le fichier de configuration

// config.php
$host = "localhost"; // db host
$user = "nobody"; // db username
$pass = ""; // db password
$db = "demo"; // db name

3.3 Installation / utilisation de la classe

Pour afficher un "poll":

include_once ("includes/miniPoll.class.php");
include_once ("config.php");
 
$connection = mysql_connect ($host, $user, $pass) or die ("Unable to connect");
mysql_select_db ($db) or die ("Unable to select database");
 
$test = new miniPoll;
 
$test->pollForm();
 
@mysql_close($connection);

3.4 Sécuriser !


UP PREVIOUS NEXT -- TIE