- Joined
- Jun 16, 2010
- Messages
- 249
- Reaction score
- 76
Poll - Vote
This script is designed to help you with decision making. All you have to do is simply write a news article, with a url to this file. Then they'll vote, and in 24 hours or so you can check the results and see their opinion.
NOTE: You must have a habbo hotel database already setup for this to work (it takes usernames from it).
The script has updated (July 15th 2010 at 12:28 (noon, -5 GMT). The bugs are fixed, I found a few.
SQL Query (run in database)
Code:
-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jul 15, 2010 at 12:31 PM
-- Server version: 5.1.41
-- PHP Version: 5.3.1
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `poll_votes`
--
-- --------------------------------------------------------
--
-- Table structure for table `poll_votes`
--
CREATE TABLE IF NOT EXISTS `poll_votes` (
`yes` text NOT NULL,
`no` text NOT NULL,
`username` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `poll_votes`
--
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Poll - Vote Script
Code:
<?php
####
##Copyright (c) TheJacob 2010##
##thejacobpollack@gmail.com##
##Public release to the community##
##Feedback - sent via email to TheJacob (listed above)##
##Support is not guaranteed, nor is safety of using this script (SQL Injections, Hex, XSS etc)##
####
####
##Instructions##
##Make a file called index.php, and copy and paste the following code in the file##
##Make a Database called "vote" in your MySQL Database area, then create a table called "poll_votes" with the following columns; "yes", "no", "username" (Or run the SQL Query to make it)##
##Fill in the configuration information and then enjoy##
####
####
##Future Features##
##-IP exist check##
####
##Configuration##
$mysql_ip = "localhost"; //MySQL IP address
$mysql_user = "root"; //MySQL username
$mysql_pw = "mypassword"; //MySQL password
$mysql_db = "poll_votes"; //MySQL database
$mysql_username_table = "users"; //MySQL username table
$mysql_username_column = "username"; //MySQL username colum
$vote_success = "Thank you for voting, your vote has been received.";
$vote_username_exist = "The username has alredy voted.";
$username_exist_no = "The username does not exist. Please enter a valid username.";
$username_enter = "Please enter a username.";
$mysql_link = mysql_connect("$mysql_ip", "$mysql_user", "$mysql_pw") or die ("Cannot connect to the MySQL database.");
$mysql_select_db = mysql_select_db("$mysql_db") or die ("Cannot select the MySQL database.");
if ((isset($_POST['submit']) == true) and (strlen($_POST['username']) == 0)) {
echo $username_enter;
}
else if ((isset($_POST['submit']) == true) and (mysql_num_rows(mysql_query("SELECT * FROM $mysql_username_table WHERE $mysql_username_column = '$_POST[username]'")) == '0')) {
echo $username_exist_no;
}
else if ((isset($_POST['submit']) == true) and (mysql_num_rows(mysql_query("SELECT * FROM poll_votes WHERE username = '$_POST[username]'")) == '1')) {
echo $vote_username_exist;
}
else if ((isset($_POST['submit']) == true) and ($_POST['no']) == true) {
$query_no = mysql_query("INSERT INTO poll_votes (yes,no,username) VALUES ('0','1','$_POST[username]')");
echo $vote_success;
}
else if ((isset($_POST['submit']) == true) and ($_POST['yes']) == true) {
$query_yes = mysql_query("INSERT INTO poll_votes (yes,no,username) VALUES ('1','0','$_POST[username]')");
echo $vote_success;
}
?>
<!-- Question -->
<b>Question:</b> Do you like this poll script?
<!-- /Question -->
<form method="post" action="#">
<table>
<tr>
<td><input type="radio" name="yes"> <b>Yes</b></td>
</tr>
<tr>
<td><input type="radio" name="no"> <b>No</b></td>
</tr>
<tr>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td><input type="submit" name="submit"></td>
</tr>
</table>
</form>
Last edited: