我想添加表單驗證,如果ip_address重複只是 留在當前頁面或給我看任何類型的消息。需要添加表單驗證codeigniter
這是模式代碼
public function add_vote($option_id)
{
$this->db->insert($this->votes_table, array(
'option_id' => $option_id,
'ip_address' => $this->input->ip_address(),
'timestamp' => time()
));
return ($this->db->affected_rows() == 1) ? TRUE : FALSE;
}
這是CONTROLER
public function vote($poll_id, $option_id)
{
if (! $this->poll_lib->vote($poll_id, $option_id))
{
$data['base_styles'] = 'public_html/res/css/base.css';
$data['title'] = 'Sorry an error occured';
$data['error_message'] = $this->poll_lib->get_errors();
$this->load->view('header');
$this->load->view('www/posts/postclose', $data);
}
else
{
redirect('posts', 'refresh');
}
}
聽到的話,我添加新的投票是顯示我的數據庫錯誤的列是重複的,所以我不要我不想表明,如果它重定向到任何其他頁面將會很好,如果留在當前頁面仍然可用或彈出消息。
任何一個........ –