NogDog, i know that many ppl changes their ip depending on pc usage or moedm, simpely to sai, dynamic ip, i know that issue, but my site doesen't need protection for multiple votes from one person using more ip's getting as many votes each one from one ip is enough, i don't care if a person changes ip and vote 1000 times, it is not a contest site, as much votes, as good to be, all i need is that votes number = ip's number, and is i told, an ip can only once vote forever.
I may help you to help me 😛
With some help, i did to get a code, but for some reasons (i think functions not defined and called) is not working.
First of all, i created in my db, a table named "voting" containing 2 rows:
1'st row: id, int(11), not null, auto_increment
2'nd row: ip varchar(15), latin1_swedish_ci, not null
Than votnig script file called "votnig.class.php"
<?php
session_start();
include("config.php");
class voting {
public function isReg() {
$sql = "SELECT ip FROM `votes` WHERE ip = '{$_SERVER['PHP_SELF']}'";
$r = mysql_query($sql) or die($sql);
if (mysql_num_rows($r) === 0) {
return true;
}
return false;
}
public function register() {
if (self::isReg()) {
$sql = "INSERT INTO `votes` (`ip`) VALUES ('{$_SERVER['PHP_SELF']}')";
mysql_query($sql) or die($sql);
return true;
}
return false;
}
public function numVotes() {
$sql = "SELECT COUNT(*) FROM `votes`";
$r = mysql_query($sql) or die($sql);
return mysql_result($r, 0);
}
}
?>
Ok, and the code that i added to my site page:
<?php
include("voting.class.php");
if (!empty($_GET['vote'])) {
if (voting::register()) {
?>Participi la campanie<?php
} else {
?>Te-ai inregistrat deja<?php
}
}
if (voting::isReg()) {
?><a href="?vote=1">Voteaza!</a><?php
} else {
?>Participi la campanie. Avem<?php echo voting::numVotes();
}
?>
Ok, i am not sure, but if this requires login, it should be removed, i don't use login on my site, i need anyone who enters can vote directly by clicking link or button(i will decide what to use as i already told in first post)
Ok and the problem i got with this code, it gives no error, but instead, everything on my page (except background image vanish and it displays the message:
SELECT ip FROM `votes` WHERE ip = '/site name/index.php'
That's my site adress, better say, a sub-site bechause this voting site is only in a folder of my main site, only a campaign like sitename.com/forum and instead of index, file is called else, the file where the voting will be dispalyed.
I hope so much that with ur help i will get script work 🙁
Thank's alot.