|
各位高手朋友,请指点,先谢谢~~
control 文件
PHP复制代码 [/code]
<?php
class Message extends CI_Controller {
function __construct (){
parent ::__construct ();
header('content-type:text/html charset=utf-8');
$this->load->helper(array('form','url'));
$this->load->model('Message_model');
$this->load->database();
$this->load->library('table');
}
function index (){
$this->load->view('message_view');
}
function post (){
$data=array(
'name'=>$this->input->post('name'),
'email'=>$this->input->post('email'),
'title'=>$this->input->post('title'),
'content'=>$this->input->post('content'),
'date'=>date('Y-m-d',time())
);
$this->Message_model->insert('message',$data);
redirect (site_url ());
}
function test (){
$shiyishi=$this->input->post('shiyishi');
$this->load->view('test_view',$shiyishi);
}
}
?>
model文件,链接数据库
[code=PHP] 复制代码
<?php
class Message_model extends CI_Model{
function __construct(){
parent::__construct();
}
function show($table='message'){
$query=$this->db->get($table);
return $query;
}
function insert($table='message',$data){
$this->db->insert($table,$data);
}
function show_where($table='message',$id){
$this->db->where('id',$id);
}
}
?>
view文件,view文件
[code=HTML][/code]
<html>
<head>
<title>我也会做留言本</title>
</head>
<h1>欢迎您给我留言,我将第一时间回复</h1>
<body>
<?php
$query=$this->Message_model->show('message');
if($query->num_rows()>0){
echo $this->table->set_heading('姓名','主题','内容','时间','留言处理');
foreach($query->result() as $row){
$delete=anchor(site_url('message/edit'.$row->id),'删除');
$reply=anchor(site_url('message/reply'.$row->id),'回复');
$row->action=array($delete,$reply);
$this->table->add_row($row->name,$row->title,$row->content,$row->name,$row->date,$row->action);
}
echo $this->table->generate();
}
echo "<hr/>";
echo form_open('message/post');
echo '<br/>姓名:'.form_input('name');
echo '<br/>邮箱:'.form_input('email');
echo '<br/>标题:'.form_input('title');
echo '<br/>内容:'.form_textarea('content');
echo form_submit('submit','提交');
echo form_close();
?>
</body>
</html>
但是view 中form_submit提交的时候要不没有反应,要不就是“网页无法访问”,我个人觉得是重定向的问题,但是又不知道如何调试,所以还请知道的朋友指导一下,谢谢了!!
|
|