Location: PHPKode > scripts > Voting system > voting-system-61721/create.php
<style type="text/css">
<!--
body {  background-color: #3333FF; font-family: "Times New Roman", Times, serif}
form {  background-color: #FF0000}
-->
</style>

<?php

$users = array(
'username' => 'password',
);
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('HTTP/1.1 401 Unautorized');
header('www-authenticate: Basic realm="PHP Secured"');
exit('This page requires authentication');
}
if(!isset($users[$_SERVER['PHP_AUTH_USER']])) {
header('HTTP/1.1 401 Unautorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unautorized!');
}
if ($users[$_SERVER['PHP_AUTH_USER']] != $_SERVER['PHP_AUTH_PW'])
{
header('HTTP/1.1 401 Unautorized');
header('WWW-Authenticate: Basic realm="PHP Secured"');
exit('Unautorized!');
}



  print "
  
  <form action=\"".$_SERVER['php_self']."\" method=\"POST\">
  Poll question<br><input type=\"text\" name=\"quest\"><br />
  a option<br><input type=\"text\" name=\"a\"><br />
  b option<br><input type=\"text\" name=\"b\"><br />
  c option<br><input type=\"text\" name=\"c\"><br />
  d option<br><input type=\"text\" name=\"d\"><br />
  <br><input type=\"submit\" name=\"action\" value=\"Send!\"><br />
  </form>
 
  ";
  
?>
<?php
if($_POST['action'])
{
  include('database.php');
  $quest=$_POST['quest'];
  $a=$_POST['a'];
  $b=$_POST['b'];
  $c=$_POST['c'];
  $d=$_POST['d'];
  $query="INSERT INTO polls1 (id, quest, a, b, c, d) VALUES (NULL, '$quest', '$a', '$b', '$c', '$d')";
  $rez=mysql_query($query);
  $query2="INSERT INTO results2 (id, quest, a, b, c, d) VALUES (NULL, '$quest', '0', '0', '0', '0')";
  $rez2=mysql_query($query2);
echo "Your poll has been succesfully created";
}
?>
Return current item: Voting system