zblogphp主题配置页面表单内容提交功能
主题配置表单信息填写后需要提交到数据库进行保存,方法如下:
在main.php模版页面编辑表单功能,因我这个页面有多个表单的提交,故而url内加上type参数进行区分,若无则'action="save.php"’即可。
<form method="post" action="save.php?type=title"> <tr> <td><p align="center">标题</p></td> <td> <textarea name="title" cols ="50" rows = "3"></textarea> </td> <td align="center"> <input type="Submit" class="button" value="保存"/> </td> </tr> </form>
在save.php页面执行保存操作
if ($_GET['type'] == 'title' ){//通过$_GET判断提交的表单,如果是type=title的表单则执行 $zbp->Config('dipper_pcqxw')->ThreeUpWen = $_POST['title'];//赋值 $zbp->SaveConfig('dipper_pcqxw');//执行保存 $zbp->SetHint('good','修改成功');//显示成功提醒 Redirect('/zb_users/theme/' . $zbp->theme .'/main.php?act=config');//跳转回主题配置页面 }
$zbp->ShowHint('good')和$zbp->SetHint('good','修改成功')区别:
ShowHint()显示消息提示,因为后面Redirect很快跳转,所以显示的瞬间看不见。
SetHint()设置提示消息并存入Cookie,跳转后还可以读取Cookie进行显示。