<?php
if(!isset($_POST['catId'])&&!isset($_POST['title'])&&!isset($_POST['desc'])&&!isset($_POST['content1'])&&!isset($_POST['recommend'])&&!isset($_POST['newsId'])){
   echo "<script>alert('文章描述太长！');history.go(-1);</script>";
   exit;
}else{
  $parentId=$_POST['catId'];
  $title=$_POST['title'];
  $desc=addslashes($_POST['desc']);
  $content=addslashes($_POST['content1']);
  $recommend=$_POST['recommend'];
  $newsId=$_POST['newsId'];
  if($title==""){
 	echo "<script>alert('请输入文章标题');history.go(-1);</script>";
 	exit;
 }
 if($desc==""){
   echo "<script>alert('请输入文章描述');history.go(-1);</script>";
 	exit;
 }
  if($content==""){
   echo "<script>alert('请输入文章内容');history.go(-1);</script>";
 	exit;
 }
  if($recommend==""){
 	echo "<script>alert('请选择是否推荐！');history.go(-1);</script>";
 	exit;
 }
 if(strlen($title)>50){
   echo "<script>alert('文章标题太长！');history.go(-1);</script>";
   exit;
 }
  if(strlen($desc)>300){
   echo "<script>alert('文章描述太长！');history.go(-1);</script>";
   exit;
 }
  include_once('conn.php');
  $sql="update news set parentId='".$parentId."', title='".$title."', content='".$content."' where newsId='".$newsId."' ";
  //mysql_query($sql,$conn) or die(mysql_error());
  if(mysql_query($sql,$conn)){
   echo "<script>alert('文章更新成功！');window.location.href='admin.php?act=viewNews';</script>";
  }else{
   echo "<script>alert('文章更新失败！');history.go(-1);</script>";
  }
 
}
?>