如何在 PHP 中创建 'Already Voted'

How to create 'Already Voted' in PHP

我得到了投票玩家的代码,但我可以投票给其他玩家

index.php

    if( @$_GET['vote'] == 'err' ) {
         $output.= "            <div class='notification error closeable'>
                <p><span>Info!</span> Poti vota serverul odata la 24 de ore.</p>
            </div>";
    }
    if( @$_GET['vote'] == 'thanks' ) {
         $output.= "<div class='notification success closeable'>
                <p><span>Info!</span> Multumim pentru vot, votul tau a fost adaugat cu success.</p>
            </div>";
    }

vote.php

<?php
require "lgsl_files/lgsl_class.php";
lgsl_database();
$id = intval( @$_GET['id']);
if( $_GET['add'] == '+1' ) {
     $rating_status = ' + 1 ';
}
elseif( $_GET['add'] == '-1' ) {
     $rating_status = ' - 1 ';
}
else {
     $rating_status = '';
}
$result = mysql_query("SELECT * FROM voting WHERE server_id = '{$id}' AND vote_ip = '{$_SERVER['REMOTE_ADDR']}' AND time > '" . ( time() - ( 60 * 60 * 24 ) ) . "'");
if( !mysql_num_rows( $result ) ) {
     $result = mysql_query("SELECT * FROM lgsl WHERE id = '{$id}'");
     if( mysql_fetch_array( $result ) ) {
          mysql_query( "INSERT INTO voting VALUES ( NULL, '{$id}', '{$_SERVER['REMOTE_ADDR']}', " . time() . ")" );
          mysql_query( "UPDATE lgsl SET rating = rating {$rating_status} WHERE id = '{$id}'" );
     }
}
else {
     @header( "Location: vot_server_respins.html" );
     exit;
}
@header( "Location: vot_server_adaugat.html" );
?>

在lgsl_class.php是统计播放器的数据库和脚本

Table Voting.sql

CREATE TABLE `voting` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `server_id` int(10) NOT NULL,
  `vote_ip` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
  `time` int(11) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=469 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

拜托,我需要很大的帮助

您应该在第一次投票后保存一个 cookie,并在每次请求时检查它。