<?php
session_start();
include("include/inc_smarty.php");
include("include/inc_db_mysql.php");

 if($_GET[action]=="huifu" && $_GET[id]!=""  && $_SESSION["usrname"]!=""){
 $sql= "SELECT `Id`, `ntitle`, `name`, `nsex`, `npic`, `msgdate`, `email`, " .
 		"`msgcontent`, `userip`, `useripadd`, `recont`, `retime`, `rstate`, " .
 		"`rqiao` FROM  gz_lstbook where Id=".$_GET[id];		//打开数据库
 $query = $db->query($sql);									//执行SQL语句返回结果
 $row = $db->fetch_row($query);								//一条数据写进数组里ROW用数字标识
 }elseif($_GET[action]=="edit" && $_GET[id]!="" && $_SESSION["usrname"]!=""){
 	$db->query("UPDATE gz_lstbook set ntitle='$_POST[ntitle]',name='$_POST[name]',nsex='$_POST[nsex]',email='$_POST[email]'," .
 			"msgcontent='$_POST[msgcontent]',recont='$_POST[recont]', retime=now(), rqiao='$_POST[rqiao]', rstate=1 where id='$_GET[id]'");
 	backurl('lst.php');
 }elseif($_GET[action]=="del" && $_GET[id]!="" && $_SESSION["usrname"]!=""){
 	$db->query("delete from gz_lstbook where id=$_GET[id]");
 	backurl('lst.php');
 }else{
 	alert('不可非法操作','lst.php');
 }
 $smarty->assign('row',$row);							//数组赋值给smarty的row
 $smarty->display("edit.htm");							//在哪个页面执行
?>

