|
小弟做的一个分步提交然后修改数据的页面.先提交栏目ID,再提交栏目信息完成修改.
遇到的问题:第二个表单提交后POST不到任何值,连原先的ID也没了直接跳回初始页.请好心人帮我看一下,在线等答案,万分感谢!
相关代码
controller:admin.php
public function update()
{
$this->load->helper('url');
$this->load->helper('form');
$this->load->database();
$data['title']="update";
$data['type']='update';
if(empty($_POST['id']))
{
$data['include']='get_boardid'; //表单页1
$this->load->view('head');
$this->load->view('content',$data);
}
elseif(!empty($_POST['id']))
{
$data['include']='update_board'; //表单页2
$data['id']=$_POST['id'];
//$_SESSION['boardid']=$_POST['id'];
$this->load->view('head');
$this->load->view('content',$data);
$this->load->model('MBoard','',TRUE);
if($this->MBoard->updateBoard()=='ok')
{
$this->load->view('success');
}
}
}
model:MBoard.php
function updateBoard()
{
if(!empty($_POST['id']))
{
$id=$_POST['id'];
$filename=$this->input->post('filename');
$name=$this->input->post('name');
$sequence=$this->input->post('sequence');
$rssnews=$this->input->post('rssnews');
$boardmenu=$this->input->post('boardmenu');
$version=$this->input->post('version');
$visible=$this->input->post('visible');
if(empty($id)||empty($filename)||empty($name)||empty($sequence)||empty($rssnews)||empty($boardmenu)||empty($version)||empty($visible))
{
echo '请输入完整数据';
}
else
{
$sql="update freeflow_board set filename='$filename',name='$name',sequence='$sequence',rssnews='$rssnews',boardmenu='$boardmenu',version='$version',visible='$visible' where id='$id'";
$this->db->query($sql);
return 'ok';
}
}
}
view:get_boardid.php //页面1用于提交ID
<?php
if($type=='update')
{
echo form_open('admin/update');
echo '修改版块';
echo "<br/>";
echo "<br/>";
}
elseif($type=='delete')
{
echo form_open('admin/drop');
echo '删除版块';
echo "<br/>";
echo "<br/>";
}
echo form_label('请输入目标版块ID','id');
$boardid = array('name' => 'id', 'id' => 'id', 'size' => '25');
echo form_input($boardid);
echo form_submit('submit','提交');
echo form_close();
?>
view:update_board.php //页面2用于修改数据
<p>请输入版块信息</p>
<?php
//echo 'data'.$id;
$_POST['id']=$id;
echo form_open('admin/update');
echo form_label('版块文件名','filename');
$filename = array('name' => 'filename', 'id' => 'filename', 'size' => '25');
echo form_input($filename);
echo form_label('版块名','name');
$name = array('name' => 'name', 'id' => 'name', 'size' => '25');
echo form_input($name);
echo form_label('排序号','sequence');
$sequence = array('name' => 'sequence', 'id' => 'sequence', 'size' => '25');
echo form_input($sequence);
echo form_label('RSS源','rssnews');
$rssnews = array('name' => 'rssnews', 'id' => 'rssnews', 'size' => '25');
echo form_input($rssnews);
echo form_label('导航菜单','boardmenu');
$boardmenu = array('name' => 'boardmenu', 'id' => 'boardmenu', 'size' => '25');
echo form_input($boardmenu);
echo form_label('版本','version');
$version = array('name' => 'version', 'id' => 'version', 'size' => '25');
?>
<select name="version" id="version">
<option value="wap2.0">wap2.0</option>
<option value="wap1.0">wap1.0</option>
<option value="speed">speed</option>
<option value="IPHONE">IPHONE</option>
<option value="3G">3G</option>
<option value="android">android</option>
<option value="touch">touch</option>
</select>
<?php
//echo form_select($version);
echo form_label('是否可见(默认为1,可见)','visible');
$visible = array('name' => 'visible', 'id' => 'visible', 'size' => '25');
echo form_input($visible);
echo form_submit('submit','提交');
echo form_close();
?>
|
|