【发布时间】:2014-03-22 01:20:09
【问题描述】:
我正在使用 CodeIgniter 开发一个网站;我正在制作一个投票网站。问题是有些条目实际上让我一次又一次地投票。他们一直在数据库中禁止 IP。
我的测试控制器:
class Vote extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{
}
public function vote_now()
{
if ($this->uri->segment(2)){
$q = $this->db->query('SELECT * FROM banned_ip WHERE entry='.$this->uri->segment(2).' LIMIT 1');
$row = $q->row_array();
$qe = $this->db->query('SELECT * FROM entries WHERE ID='.$this->uri->segment(2).' LIMIT 1');
$r = $qe->row_array();
if($row['IP'] == $this->input->ip_address()){
echo 'Already Voted.';
}
else {
$insert_data_votes = array(
'votes' => $r['votes']+1,
);
$this->db->where('ID', $this->uri->segment(2))->update('entries', $insert_data_votes);
$insert_data = array(
'IP' => $this->input->ip_address(),
'entry' => $this->uri->segment(2),
);
$this->db->insert('banned_ip', $insert_data);
redirect('foto/'.$this->uri->segment(2).'', 'refresh');
}
}
}}
有人知道这是什么问题吗?
谢谢。
【问题讨论】:
-
您期望
$this->uri->segment(2)中的价值类型是什么? -
那是要投票的 fotoID。我需要检查 fotoID 是否附有禁止 IP。
-
我的 Bans 数据库是.. 条目(照片)和 IP
标签: php database codeigniter vote