<?php
    session_start(); 
	require_once('inc/conn.php');
	require_once('inc/constant.php');
	require_once('inc/ls_syscode.php');
	require_once('inc/check.php');
	$opendb=new mydb();
	require_once('inc/char_set.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
		<title>无标题文档</title>
	</head>

	<body>
<?php



	$ls=$_POST['ls'];
	$id=$_POST['id'];
	$pageTitle=$_POST['pageTitle'];
	$pageText=$_POST['pageText'];
	$pageBrief=$_POST['pageBrief'];
	$pageDate=$_POST['pageDate'];
	$cate="singlePages";
	$Num=$_POST['Num'];

	
	switch($ls)
	{
		case "insert":
		
			$insert_sql=sprintf("insert into ls_singlepages (pageTitle,pageText,pageDate,enable,pageBrief,cate,Num) values (%s,%s,%s,%s,%s,%s,%s)",
						GetSQLValueString($pageTitle,"text"),
						GetSQLValueString($pageText,"text"),
						GetSQLValueString(date("Y-m-d"),"date"),
						GetSQLValueString("1", "int"),
						GetSQLValueString($pageBrief,"text"),
						GetSQLValueString($cate,"text"),
						GetSQLValueString($Num,"int")
						);
			$insert_query=$opendb->query($insert_sql);
			echo "<script>alert('添加成功！');location='singlepage.php';</script>";
			break;
			
		case "update":
	$update_sql=sprintf("update ls_singlepages  set pageTitle=%s,pageText=%s,pageBrief=%s,pageDate=%s,enable=%s,cate=%s,Num=%s where id=%s",
						GetSQLValueString($pageTitle,"text"),
						GetSQLValueString($pageText,"text"),
						GetSQLValueString($pageBrief,"text"),
						GetSQLValueString($pageDate,"date"),
						GetSQLValueString("1", "int"),
						GetSQLValueString($cate,"text"),
						GetSQLValueString($Num, "int"),
						GetSQLValueString($id,"int")
						);
									//echo $update_sql;
			$update_query=$opendb->query($update_sql);
			echo "<script>alert('更新成功！');location='singlepage.php';</script>";
	}
?>
</body>
</html>