-
Notifications
You must be signed in to change notification settings - Fork 0
/
comment.php
36 lines (29 loc) · 930 Bytes
/
comment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
class Comment extends HomeController{
function index(){
}
function add_comment(){
$this->load->library('form_validation');
$this->form_validation->set_rules('name', '姓名', 'required');
$this->form_validation->set_rules('phone', '手机', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('msg','填写错误,请重新填写');
if( $this->input->post('dosubmit') ==='' ) redirect($_SERVER['HTTP_REFERER'].'#myform');
redirect($_SERVER['HTTP_REFERER']);
}
else
{
$data = array(
'user_name'=>$this->input->post('name'),
'tel' => $this->input->post('phone'),
'content' => $this->input->post('content'),
'createtime' => time(),
);
auto_charset($data,'utf-8','gbk');
$this->db->insert('comments',$data);
$this->session->set_flashdata('msg','预定成功');
redirect($_SERVER['HTTP_REFERER']);
}
}
}