如何在PHP中创建“已经投票”

问题描述 投票:-1回答:1

我得到投票选手的代码,但我可以投票给其他球员

的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中是统计播放器的数据库和脚本

表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 */;

我需要非常大的帮助

php mysql sql get rating
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.