1 Pagina Poll
Auteur: Martijn1515 - 28 maart 2006 - 15:35 - Gekeurd door: nemesiskoen - Hits: 26102 - Aantal punten: 3.95 (10 stemmen)
Uitleg ---
Dit Poll Systeem, is een uniek systeem omdat het gebruik maakt van 1 bestand : poll.php en 1 database met 6 kolommen.
Poll : www.url.nl/poll.php
Admin Poll : www.url.nl/poll.php?action=inloggen
Gebruikersnaam : admin
Wachtwoord : admin
Installatie ---
Maak een database aan, en zet daar sql.sql in
Wijzig in poll.php, de Database gegevens.
Uploaden, en hij doet het.
Problemen ---
Reageer of stuur een PM.
Code:
Poll.php
<?php
session_start();
/* Config */
// Aanpassen aan JOUW DB!
$DB = Array(
"dbhost" => "localhost",
"dbuser" => "******", // Database gebruiker
"dbpas" => "******", // Database wachtwoord
"dbname" => "******" // Database naam
);
/* Mysql connectie maken */
mysql_connect($DB['dbhost'],$DB['dbuser'],$DB['dbpas']) or die ("<CODE>Sorry, connectie is verbroken.</CODE>");
mysql_select_db($DB['dbname']) or die ("<CODE>Sorry, connectie is verbroken.</CODE>");
$admingebruikersnaam = "admin"; // Naam van de Admin
$adminwachtwoord = "admin"; // Het wachtwoord van de Admin
$action = $_GET['action'];
$tabel = "poll"; // Tabel waar de poll in staat
echo "<LINK REL='stylesheet' HREF='style.css' TYPE='text/css'>";
//Inloggen
if($_SESSION['gebruikersnaam'] == $admingebruikersnaam && $_SESSION['wachtwoord'] == $adminwachtwoord) {
$ingelogd = 1;
} else {
$ingelogd = 0;
}
/* Config */
/* Function voor de Poll */
function poll()
{
$tabel = "poll"; // Tabel waar de poll in staat
//
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$obj = mysql_fetch_assoc($select);
$id = $obj['id'];
$select = mysql_query("SELECT * FROM `$tabel` WHERE `ip` LIKE '%". $_SERVER['REMOTE_ADDR'] ."%' AND `id` = '$id' ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$aantal = mysql_num_rows($select);
$obj = mysql_fetch_assoc($select);
//
if($aantal > 0) {
echo pollresultaat();
} else {
echo pollstemmen();
}
}
function pollstemmen()
{
$tabel = "poll"; // Tabel waar de poll in staat
if(isset($_POST['submit'])) {
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$obj = mysql_fetch_assoc($select);
$id = $obj['id'];
$select = mysql_query("SELECT * FROM `$tabel` WHERE `ip` LIKE '%". $_SERVER['REMOTE_ADDR'] ."%' AND `id` = '$id' ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$aantal = mysql_num_rows($select);
$obj = mysql_fetch_assoc($select);
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$obj = mysql_fetch_assoc($select);
if($aantal > 0) {
echo "Je hebt al gestemd!<br><br>";
echo pollresultaat();
} else {
$stem = $_POST['radio'];
$a = $obj['stemmen'];
$totalb = count(explode(",", $a));
$b = explode(",", $a);
$b[$stem] = $b[$stem] + 1;
$i = 0;
$i2 = 1;
while($i < $totalb) {
$stem2 .= $b[$i];
if($i2 < $totalb) {
$stem2 .= ",";
}
$i++;
$i2++;
}
mysql_query("UPDATE `$tabel` SET `stemmen` = '$stem2', `ip` = CONCAT(ip,' " . $_SERVER['REMOTE_ADDR'] . "') ORDER BY `id` DESC LIMIT 1")or die(Mysql_Error());
echo pollresultaat();
}
} else {
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$aantal = mysql_num_rows($select);
if($aantal == 1) {
$obj = mysql_fetch_assoc($select);
$a = $obj['antwoorden'];
$totala = count(explode(",", $a));
$a = explode(",", $a);
$b = $obj['stemmen'];
$totalb = count(explode(",", $b));
$b = explode(",", $b);
$totalc = array_sum($b);
if($totala == $totalb) {
echo $obj['vraag'] ." (". $totalc .")<br>";
echo "<table><form action='' method='post'>";
$i = 0;
while($i < $totala) {
$antwoord = $a[$i];
$stemmen = $b[$i];
echo "<tr><td><input name='radio' type='radio' class='radio' value='". $i ."'> ". $antwoord ." (". $stemmen .")</td>";
if($stemmen == 0) {
echo "<td><img src='vol.jpg' width='1' height='10'><img src='leeg.jpg' width='99' height='10'></td></tr>";
} else {
$score = round(100 / $totalc * $stemmen,0);
$af = 100 - $score;
echo "<td><img src='vol.jpg' width='". $score ."' height='10'><img src='leeg.jpg' width='". $af ."' height='10'></td></tr>";
}
$i++;
}
echo "<tr><td colspan='2'><input type='submit' value='Stem' name='submit'></td></tr></table>";
} else {
echo "Error";
}
} else {
echo "Er is op dit moment nog geen poll.";
}
}
}
function pollresultaat()
{
$tabel = "poll"; // Tabel waar de poll in staat
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$aantal = mysql_num_rows($select);
if($aantal == 1) {
$obj = mysql_fetch_assoc($select);
$a = $obj['antwoorden'];
$totala = count(explode(",", $a));
$a = explode(",", $a);
$b = $obj['stemmen'];
$totalb = count(explode(",", $b));
$b = explode(",", $b);
$totalc = array_sum($b);
if($totala == $totalb) {
echo $obj['vraag'] ." (". $totalc .")<br>";
echo "<table>";
$i = 0;
while($i < $totala) {
$antwoord = $a[$i];
$stemmen = $b[$i];
echo "<tr><td>". $antwoord ." (". $stemmen .")</td>";
if($stemmen == 0) {
echo "<td><img src='vol.jpg' width='1' height='10'><img src='leeg.jpg' width='99' height='10'></td></tr>";
} else {
$score = round(100 / $totalc * $stemmen,0);
$af = 100 - $score;
echo "<td><img src='vol.jpg' width='". $score ."' height='10'><img src='leeg.jpg' width='". $af ."' height='10'></td></tr>";
}
$i++;
}
echo "</table>";
} else {
echo "Error";
}
} else {
echo "Er is op dit moment nog geen poll.";
}
}
/* Function voor de Poll */
/* Poll */
if($action == "") {
echo poll();
} elseif($action == "inloggen") {
if($ingelogd == 0) {
if(isset($_POST['submit'])) {
if(empty($_POST['gebruikersnaam'])) {
echo "Vul een gebruikersnaam in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} elseif(empty($_POST['wachtwoord'])) {
echo "Vul een wachtwoord in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} elseif($_POST['gebruikersnaam'] != $admingebruikersnaam) {
echo "Vul de juiste gebruikersnaam in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} elseif($_POST['wachtwoord'] != $adminwachtwoord) {
echo "Vul het juiste wachtwoord in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} else {
$_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
$_SESSION['gebruikersnaam'] = $_POST['gebruikersnaam'];
$_SESSION['wachtwoord'] = $_POST['wachtwoord'];
echo "Welkom ". $_POST['gebruikersnaam'] .", een ogenblik geduld alstubliefd.";
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>";
}
} else {
?>
<form action='' method='post'>
<table>
<tr><td>Gebruikersnaam :</td><td><input name='gebruikersnaam' type="text" value=""></td></tr>
<tr><td>Wachtwoord :</td><td><input name='wachtwoord' type="password" value=""></td></tr>
<tr><td colspan='2'><input type="submit" value="Inloggen!" name='submit'> <input type="reset" value="Leeg maken!"></td></tr>
</table>
</form>
<?
}
} else {
echo "Je bent al ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>.";
}
} elseif($action == "uitloggen") {
if($ingelogd == 1) {
$_SESSION = array();
session_destroy();
echo "Je bent nu uitgelogd. Nog een fijne dag.";
} else {
echo "Je bent nog niet ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>.";
}
} elseif($action == "admin") {
if($ingelogd == 1) {
$level = $_GET['level'];
if($level == "") {
echo "Welkom ". $_SESSION['gebruikersnaam'] .", kies uit het menu.<br><br>";
echo "<a href='poll.php?action=admin&level=nieuw'>Maak een nieuwe poll aan</a><br>";
echo "<a href='poll.php?action=admin&level=bewerk'>Bewerk de poll</a><br>";
echo "<a href='poll.php?action=admin&level=verwijder'>Verwijder de poll</a><br>";
echo "<a href='poll.php?action=admin&level=verwijderall'>Verwijder alle polls in het archief</a><br><br>";
echo "<a href='poll.php?action=uitloggen'>Uitloggen</a><br><br>";
echo poll();
} elseif($level == "nieuw") {
if(isset($_POST['voegtoe'])) {
if(empty($_POST['vraag'])) {
echo "Vul een vraag in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} else {
$aantal = $_POST['aantal'];
$vraag = $_POST['vraag'];
$i = 1;
while($i <= $aantal) {
$antwoord .= $_POST[$i];
$stem .= "0";
if($i < $aantal) {
$antwoord .= ",";
}
if($i < $aantal) {
$stem .= ",";
}
$i++;
}
$tijd = time();
mysql_query("INSERT INTO `$tabel` (vraag,antwoorden,stemmen,datum) VALUES ('". $vraag ."', '". $antwoord ."', '". $stem ."', '". $tijd ."')") or die (Mysql_Error());
echo "De nieuwe poll is in de database opgeslagen. Een ogenblik geduld alstubliefd.";
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>";
}
} else {
$aantal = $_POST['aantal'];
if($aantal == "" OR !is_numeric($aantal)) {
echo "Hoeveel antwoorden heb je nodig?";
echo "<form action='' method='post'>";
echo "<select size='1' name='aantal'>";
echo "<option value=''></option>";
$i = 2;
while($i <= 25) {
echo "<option value='". $i ."'>". $i ."</option>";
$i++;
}
echo "</select><br>";
echo "<input type='submit' value='Ga Veder' name='submit'>";
echo "</form>";
} else {
?>
<form action='' method='post'>
<input name="aantal" type="hidden" value="<?php echo $aantal; ?>">
<table>
<tr><td>Vraag :</td><td><input name="vraag" type="text" value="" maxlength='100'></td></tr>
<?
$i = 1;
while($i <= $aantal) {
echo "<tr><td>Antwoord ". $i ." :</td><td><input name='". $i ."' type='text' value=''></td></tr>";
$i++;
}
?>
<tr><td colspan='2'><input type="submit" value="Voeg Toe!" name="voegtoe"> <input type="reset" value="Leeg Maken!"></td></tr>
</table>
</form>
<?
}
}
} elseif($level == "bewerk") {
$select = mysql_query("SELECT * FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
$aantal = mysql_num_rows($select);
$obj = mysql_fetch_assoc($select);
if($aantal > 0) {
if(isset($_POST['submit'])) {
if(empty($_POST['vraag'])) {
echo "Vul wel een vraag in! <a href='javascript:history.go(-1)'>Ga terug</a>.";
} else {
$aantal = $_POST['aantal'];
$vraag = $_POST['vraag'];
$i = 1;
while($i <= $aantal) {
$antwoord .= $_POST[$i];
if($i < $aantal) {
$antwoord .= ",";
}
$i++;
}
$tijd = time();
mysql_query("UPDATE `$tabel` SET `vraag` = '$vraag', `antwoorden` = '$antwoord' WHERE id = '". $obj['id'] ."'") or die (Mysql_Error());
echo "De poll is bewerkt en in de database opgeslagen. Een ogenblik geduld alstubliefd.";
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>";
}
} else {
$a = $obj['antwoorden'];
$total = count(explode(",", $a));
$a = explode(",", $a);
?>
<form action='' method='post'>
<input name="aantal" type="hidden" value="<?php echo $total; ?>">
<table>
<tr><td>Vraag :</td><td><input name="vraag" type="text" value="<?php echo $obj['vraag']; ?>" maxlength='100'></td></tr>
<?
$i = 1;
$i2 = 0;
while($i <= $total) {
$antwoord = $a[$i2];
echo "<tr><td>Antwoord ". $i ." :</td><td><input name='". $i ."' type='text' value='". $antwoord ."'></td></tr>";
$i++;
$i2++;
}
?>
<tr><td colspan='2'><input type="submit" value="Bewerk!" name="submit"> <input type="reset" value="Reset!"></td></tr>
</table>
</form>
<?
}
} else {
echo "Er bestaat nog geen poll.";
}
} elseif($level == "verwijder") {
if(isset($_POST['ja'])) {
mysql_query("DELETE FROM `$tabel` ORDER BY `id` DESC LIMIT 1") or die (Mysql_Error());
echo "Je hebt de laatste poll verwijderd. Een ogenblik geduld alstubliefd.";
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>";
} elseif(isset($_POST['nee'])) {
echo "<meta http-equiv='refresh' content='0;url=poll.php?action=admin'>";
} else {
?>
Weet je zeker dat je de laatste poll uit het archief wilt verwijderen?<br>
<form action='' method='post'> <input type="submit" value="Ja" name='ja'> <input type="submit" value="Nee" name='nee'> </form>
<?
}
} elseif($level == "verwijderall") {
if(isset($_POST['ja'])) {
mysql_query("DELETE FROM `$tabel`") or die (Mysql_Error());
echo "Je hebt alle polls verwijderd. Een ogenblik geduld alstubliefd.";
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>";
} elseif(isset($_POST['nee'])) {
echo "<meta http-equiv='refresh' content='0;url=poll.php?action=admin'>";
} else {
?>
Weet je zeker dat je alle poll's uit het archief wilt verwijderen?<br>
<form action='' method='post'> <input type="submit" value="Ja" name='ja'> <input type="submit" value="Nee" name='nee'> </form>
<?
}
}
} else {
echo "Je bent nog niet ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>.";
}
} else {
echo "Fout! <a href='javascript:history.go(-1)'>Ga terug</a>.";
}
/* Poll */
?>
<?php
/* Config */
// Aanpassen aan JOUW DB!
"dbhost" => "localhost" ,
"dbuser" => "******" , // Database gebruiker
"dbpas" => "******" , // Database wachtwoord
"dbname" => "******" // Database naam
) ;
/* Mysql connectie maken */
mysql_connect ( $DB [ 'dbhost' ] , $DB [ 'dbuser' ] , $DB [ 'dbpas' ] ) or
die ( "<CODE>Sorry, connectie is verbroken.</CODE>" ) ;
$admingebruikersnaam = "admin" ; // Naam van de Admin
$adminwachtwoord = "admin" ; // Het wachtwoord van de Admin
$action = $_GET [ 'action' ] ;
$tabel = "poll" ; // Tabel waar de poll in staat
echo "<LINK REL='stylesheet' HREF='style.css' TYPE='text/css'>" ;
//Inloggen
if ( $_SESSION [ 'gebruikersnaam' ] == $admingebruikersnaam && $_SESSION [ 'wachtwoord' ] == $adminwachtwoord ) {
$ingelogd = 1 ;
} else {
$ingelogd = 0 ;
}
/* Config */
/* Function voor de Poll */
function poll( )
{
$tabel = "poll" ; // Tabel waar de poll in staat
//
$id = $obj [ 'id' ] ;
$select = mysql_query ( "SELECT * FROM `$tabel ` WHERE `ip` LIKE '%" . $_SERVER [ 'REMOTE_ADDR' ] . "%' AND `id` = '$id ' ORDER BY `id` DESC LIMIT 1" ) or
die ( Mysql_Error ( ) ) ;
//
if ( $aantal > 0 ) {
} else {
}
}
function pollstemmen( )
{
$tabel = "poll" ; // Tabel waar de poll in staat
if ( isset ( $_POST [ 'submit' ] ) ) {
$id = $obj [ 'id' ] ;
$select = mysql_query ( "SELECT * FROM `$tabel ` WHERE `ip` LIKE '%" . $_SERVER [ 'REMOTE_ADDR' ] . "%' AND `id` = '$id ' ORDER BY `id` DESC LIMIT 1" ) or
die ( Mysql_Error ( ) ) ;
if ( $aantal > 0 ) {
echo "Je hebt al gestemd!<br><br>" ;
} else {
$stem = $_POST [ 'radio' ] ;
$a = $obj [ 'stemmen' ] ;
$b [ $stem ] = $b [ $stem ] + 1 ;
$i = 0 ;
$i2 = 1 ;
while ( $i < $totalb ) {
$stem2 .= $b [ $i ] ;
if ( $i2 < $totalb ) {
$stem2 .= "," ;
}
$i ++;
$i2 ++;
}
mysql_query ( "UPDATE `$tabel ` SET `stemmen` = '$stem2 ', `ip` = CONCAT(ip,' " . $_SERVER [ 'REMOTE_ADDR' ] . "') ORDER BY `id` DESC LIMIT 1" ) or
die ( Mysql_Error ( ) ) ; }
} else {
if ( $aantal == 1 ) {
$a = $obj [ 'antwoorden' ] ;
$b = $obj [ 'stemmen' ] ;
if ( $totala == $totalb ) {
echo $obj [ 'vraag' ] . " (" . $totalc . ")<br>" ; echo "<table><form action='' method='post'>" ;
$i = 0 ;
while ( $i < $totala ) {
$antwoord = $a [ $i ] ;
$stemmen = $b [ $i ] ;
echo "<tr><td><input name='radio' type='radio' class='radio' value='" . $i . "'> " . $antwoord . " (" . $stemmen . ")</td>" ;
if ( $stemmen == 0 ) {
echo "<td><img src='vol.jpg' width='1' height='10'><img src='leeg.jpg' width='99' height='10'></td></tr>" ; } else {
$score = round ( 100 / $totalc * $stemmen , 0 ) ; $af = 100 - $score ;
echo "<td><img src='vol.jpg' width='" . $score . "' height='10'><img src='leeg.jpg' width='" . $af . "' height='10'></td></tr>" ; }
$i ++;
}
echo "<tr><td colspan='2'><input type='submit' value='Stem' name='submit'></td></tr></table>" ; } else {
}
} else {
echo "Er is op dit moment nog geen poll." ; }
}
}
function pollresultaat( )
{
$tabel = "poll" ; // Tabel waar de poll in staat
if ( $aantal == 1 ) {
$a = $obj [ 'antwoorden' ] ;
$b = $obj [ 'stemmen' ] ;
if ( $totala == $totalb ) {
echo $obj [ 'vraag' ] . " (" . $totalc . ")<br>" ;
$i = 0 ;
while ( $i < $totala ) {
$antwoord = $a [ $i ] ;
$stemmen = $b [ $i ] ;
echo "<tr><td>" . $antwoord . " (" . $stemmen . ")</td>" ;
if ( $stemmen == 0 ) {
echo "<td><img src='vol.jpg' width='1' height='10'><img src='leeg.jpg' width='99' height='10'></td></tr>" ; } else {
$score = round ( 100 / $totalc * $stemmen , 0 ) ; $af = 100 - $score ;
echo "<td><img src='vol.jpg' width='" . $score . "' height='10'><img src='leeg.jpg' width='" . $af . "' height='10'></td></tr>" ; }
$i ++;
}
} else {
}
} else {
echo "Er is op dit moment nog geen poll." ; }
}
/* Function voor de Poll */
/* Poll */
if ( $action == "" ) {
} elseif ( $action == "inloggen" ) {
if ( $ingelogd == 0 ) {
if ( isset ( $_POST [ 'submit' ] ) ) {
if ( empty ( $_POST [ 'gebruikersnaam' ] ) ) {
echo "Vul een gebruikersnaam in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} elseif ( empty ( $_POST [ 'wachtwoord' ] ) ) {
echo "Vul een wachtwoord in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} elseif ( $_POST [ 'gebruikersnaam' ] != $admingebruikersnaam ) {
echo "Vul de juiste gebruikersnaam in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} elseif ( $_POST [ 'wachtwoord' ] != $adminwachtwoord ) {
echo "Vul het juiste wachtwoord in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} else {
$_SESSION [ 'ip' ] = $_SERVER [ 'REMOTE_ADDR' ] ;
$_SESSION [ 'gebruikersnaam' ] = $_POST [ 'gebruikersnaam' ] ;
$_SESSION [ 'wachtwoord' ] = $_POST [ 'wachtwoord' ] ;
echo "Welkom " . $_POST [ 'gebruikersnaam' ] . ", een ogenblik geduld alstubliefd." ;
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>" ;
}
} else {
?>
<form action='' method='post'>
<table>
<tr><td>Gebruikersnaam :</td><td><input name='gebruikersnaam' type="text" value=""></td></tr>
<tr><td>Wachtwoord :</td><td><input name='wachtwoord' type="password" value=""></td></tr>
<tr><td colspan='2'><input type="submit" value="Inloggen!" name='submit'> <input type="reset" value="Leeg maken!"></td></tr>
</table>
</form>
<?
}
} else {
echo "Je bent al ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
}
} elseif ( $action == "uitloggen" ) {
if ( $ingelogd == 1 ) {
echo "Je bent nu uitgelogd. Nog een fijne dag." ;
} else {
echo "Je bent nog niet ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
}
} elseif ( $action == "admin" ) {
if ( $ingelogd == 1 ) {
$level = $_GET [ 'level' ] ;
if ( $level == "" ) {
echo "Welkom " . $_SESSION [ 'gebruikersnaam' ] . ", kies uit het menu.<br><br>" ;
echo "<a href='poll.php?action=admin&level=nieuw'>Maak een nieuwe poll aan</a><br>" ; echo "<a href='poll.php?action=admin&level=bewerk'>Bewerk de poll</a><br>" ; echo "<a href='poll.php?action=admin&level=verwijder'>Verwijder de poll</a><br>" ; echo "<a href='poll.php?action=admin&level=verwijderall'>Verwijder alle polls in het archief</a><br><br>" ;
echo "<a href='poll.php?action=uitloggen'>Uitloggen</a><br><br>" ;
} elseif ( $level == "nieuw" ) {
if ( isset ( $_POST [ 'voegtoe' ] ) ) {
if ( empty ( $_POST [ 'vraag' ] ) ) {
echo "Vul een vraag in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} else {
$aantal = $_POST [ 'aantal' ] ;
$vraag = $_POST [ 'vraag' ] ;
$i = 1 ;
while ( $i <= $aantal ) {
$antwoord .= $_POST [ $i ] ;
$stem .= "0" ;
if ( $i < $aantal ) {
$antwoord .= "," ;
}
if ( $i < $aantal ) {
$stem .= "," ;
}
$i ++;
}
mysql_query ( "INSERT INTO `$tabel ` (vraag,antwoorden,stemmen,datum) VALUES ('" . $vraag . "', '" . $antwoord . "', '" . $stem . "', '" . $tijd . "')" ) or
die ( Mysql_Error ( ) ) ; echo "De nieuwe poll is in de database opgeslagen. Een ogenblik geduld alstubliefd." ;
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>" ; }
} else {
$aantal = $_POST [ 'aantal' ] ;
echo "Hoeveel antwoorden heb je nodig?" ;
echo "<form action='' method='post'>" ; echo "<select size='1' name='aantal'>" ; echo "<option value=''></option>" ;
$i = 2 ;
while ( $i <= 25 ) {
echo "<option value='" . $i . "'>" . $i . "</option>" ; $i ++;
}
echo "<input type='submit' value='Ga Veder' name='submit'>" ;
} else {
?>
<form action='' method='post'>
<input name="aantal" type="hidden" value="
<?php echo $aantal ; ?> ">
<table>
<tr><td>Vraag :</td><td><input name="vraag" type="text" value="" maxlength='100'></td></tr>
<?
$i = 1 ;
while ( $i <= $aantal ) {
echo "<tr><td>Antwoord " . $i . " :</td><td><input name='" . $i . "' type='text' value=''></td></tr>" ;
$i ++;
}
?>
<tr><td colspan='2'><input type="submit" value="Voeg Toe!" name="voegtoe"> <input type="reset" value="Leeg Maken!"></td></tr>
</table>
</form>
<?
}
}
} elseif ( $level == "bewerk" ) {
if ( $aantal > 0 ) {
if ( isset ( $_POST [ 'submit' ] ) ) {
if ( empty ( $_POST [ 'vraag' ] ) ) {
echo "Vul wel een vraag in! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
} else {
$aantal = $_POST [ 'aantal' ] ;
$vraag = $_POST [ 'vraag' ] ;
$i = 1 ;
while ( $i <= $aantal ) {
$antwoord .= $_POST [ $i ] ;
if ( $i < $aantal ) {
$antwoord .= "," ;
}
$i ++;
}
mysql_query ( "UPDATE `$tabel ` SET `vraag` = '$vraag ', `antwoorden` = '$antwoord ' WHERE id = '" . $obj [ 'id' ] . "'" ) or
die ( Mysql_Error ( ) ) ; echo "De poll is bewerkt en in de database opgeslagen. Een ogenblik geduld alstubliefd." ;
echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>" ; }
} else {
$a = $obj [ 'antwoorden' ] ;
?>
<form action='' method='post'>
<input name="aantal" type="hidden" value="
<?php echo $total ; ?> ">
<table>
<tr><td>Vraag :</td><td><input name="vraag" type="text" value="
<?php echo $obj [ 'vraag' ] ; ?> " maxlength='100'></td></tr>
<?
$i = 1 ;
$i2 = 0 ;
while ( $i <= $total ) {
$antwoord = $a [ $i2 ] ;
echo "<tr><td>Antwoord " . $i . " :</td><td><input name='" . $i . "' type='text' value='" . $antwoord . "'></td></tr>" ;
$i ++;
$i2 ++;
}
?>
<tr><td colspan='2'><input type="submit" value="Bewerk!" name="submit"> <input type="reset" value="Reset!"></td></tr>
</table>
</form>
<?
}
} else {
echo "Er bestaat nog geen poll." ;
}
} elseif ( $level == "verwijder" ) {
if ( isset ( $_POST [ 'ja' ] ) ) {
echo "Je hebt de laatste poll verwijderd. Een ogenblik geduld alstubliefd." ; echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>" ;
} elseif ( isset ( $_POST [ 'nee' ] ) ) {
echo "<meta http-equiv='refresh' content='0;url=poll.php?action=admin'>" ;
} else {
?>
Weet je zeker dat je de laatste poll uit het archief wilt verwijderen?<br>
<form action='' method='post'> <input type="submit" value="Ja" name='ja'> <input type="submit" value="Nee" name='nee'> </form>
<?
}
} elseif ( $level == "verwijderall" ) {
if ( isset ( $_POST [ 'ja' ] ) ) {
echo "Je hebt alle polls verwijderd. Een ogenblik geduld alstubliefd." ; echo "<meta http-equiv='refresh' content='3;url=poll.php?action=admin'>" ;
} elseif ( isset ( $_POST [ 'nee' ] ) ) {
echo "<meta http-equiv='refresh' content='0;url=poll.php?action=admin'>" ;
} else {
?>
Weet je zeker dat je alle poll's uit het archief wilt verwijderen?<br>
<form action='' method='post'> <input type="submit" value="Ja" name='ja'> <input type="submit" value="Nee" name='nee'> </form>
<?
}
}
} else {
echo "Je bent nog niet ingelogd! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
}
} else {
echo "Fout! <a href='javascript:history.go(-1)'>Ga terug</a>." ;
}
/* Poll */
?>
Sql.sql
-- Tabel structuur voor tabel `poll`
CREATE TABLE `poll` (
`id` int(11) NOT NULL auto_increment,
`vraag` varchar(100) NOT NULL default '',
`antwoorden` text NOT NULL,
`stemmen` text NOT NULL,
`ip` text NOT NULL,
`datum` int(20) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=2 ;
--
-- Gegevens worden uitgevoerd voor tabel `poll`
--
INSERT INTO `poll` VALUES (1, 'Wat vind je van deze poll?', 'Geweldig,Gaaf,Gaat,Minder', '0,0,0,0', '', 1143552256);
-- Tabel structuur voor tabel `poll`
CREATE TABLE `poll` (
`id` int( 11 ) NOT NULL auto_increment,
`vraag` varchar( 100 ) NOT NULL default '' ,
`antwoorden` text NOT NULL ,
`stemmen` text NOT NULL ,
`ip` text NOT NULL ,
`datum` int( 20 ) NOT NULL default '0' ,
) TYPE= MyISAM AUTO_INCREMENT= 2 ;
--
-- Gegevens worden uitgevoerd voor tabel `poll`
--
INSERT INTO `poll` VALUES ( 1 , 'Wat vind je van deze poll?' , 'Geweldig,Gaaf,Gaat,Minder' , '0,0,0,0' , '' , 1143552256 ) ;
Style.css
body,table {
font: 8pt arial;
color: #000000;
font-weight: normal;
background-color: #EEEEEE;
scrollbar-base-color: #EEEEEE;
scrollbar-track-color: #FFFFFF;
scrollbar-face-color: #EEEEEE;
scrollbar-highlight-color: #FFFFFF;
scrollbar-3d-light-color: #EEEEEE;
scrollbar-darkshadow-color: #C0C0C0;
scrollbar-shadow-color: #CCCCCC;
scrollbar-arrow-color: #FFFFFF;
}
a:link {
color: #000000;
text-decoration: underline;
}
a:visited {
color: #000000;
text-decoration: underline;
}
a:hover {
color: #292929;
text-decoration: underline;
}
a:active {
color: #383838;
text-decoration: none;
}
html {
scrollbar-base-color: #000000;
scrollbar-3dlight-color: #CCCCCC;
scrollbar-arrow-color: #000000;
scrollbar-darkshadow-color: #CCCCCC;
scrollbar-face-color: #FFFFFF;
scrollbar-highlight-color: #000000;
scrollbar-shadow-color: #000000;
scrollbar-track-color: #E8E4D8;
}
input {
border: 1px solid black;
font-family: Arial;
font-size: 8pt;
color: #000000;
background-color: #C0C0C0;
}
radio {
border: 1px solid black;
font-size: 8pt;
color: #000000;
background-color: #C0C0C0;
}
textarea {
border: 1px solid black;
font-family: Arial;
font-size: 8pt;
color: #000000;
background-color: #C0C0C0;
}
select {
border: 1px solid black;
font-family: Arial;
font-size: 8pt;
color: #000000;
background-color: #C0C0C0;
}
body, table {
font: 8pt arial;
color: #000000;
font- weight: normal;
background- color: #EEEEEE;
scrollbar- base- color: #EEEEEE;
scrollbar- track- color: #FFFFFF;
scrollbar- face- color: #EEEEEE;
scrollbar- highlight- color: #FFFFFF;
scrollbar- 3d- light- color: #EEEEEE;
scrollbar- darkshadow- color: #C0C0C0;
scrollbar- shadow- color: #CCCCCC;
scrollbar- arrow- color: #FFFFFF;
}
color: #000000;
text- decoration: underline;
}
a: visited {
color: #000000;
text- decoration: underline;
}
a: hover {
color: #292929;
text- decoration: underline;
}
a: active {
color: #383838;
text- decoration: none;
}
html {
scrollbar- base- color: #000000;
scrollbar- 3dlight- color: #CCCCCC;
scrollbar- arrow- color: #000000;
scrollbar- darkshadow- color: #CCCCCC;
scrollbar- face- color: #FFFFFF;
scrollbar- highlight- color: #000000;
scrollbar- shadow- color: #000000;
scrollbar- track- color: #E8E4D8;
}
input {
border: 1px solid black;
font- family: Arial;
font- size: 8pt;
color: #000000;
background- color: #C0C0C0;
}
radio {
border: 1px solid black;
font- size: 8pt;
color: #000000;
background- color: #C0C0C0;
}
textarea {
border: 1px solid black;
font- family: Arial;
font- size: 8pt;
color: #000000;
background- color: #C0C0C0;
}
select {
border: 1px solid black;
font- family: Arial;
font- size: 8pt;
color: #000000;
background- color: #C0C0C0;
}
Download code (.txt)
Stemmen
Niet ingelogd.