<?php
$conn = mysql_connect("127.0.0.1:3306","root","root");
mysql_select_db("test");
mysql_query("set names gbk");
?>
<?php
require_once 'checkadmin.php';
?>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="css/admin.css" type="text/css" rel="stylesheet">
<title>添加新聞</title>
</HEAD>
<BODY>
<TABLE width="90%" height="18" border=0 align=center cellPadding=0 cellSpacing=0>
<TR height=28>
<TD p_w_picpaths /title_bg1.jpg>當前位置:添加新聞 </TD></TR>
<TR>
<TD bgColor=#b1ceef height=1></TD></TR>
<TR height=20>
<TD p_w_picpaths /shadow_bg.jpg></TD></TR></TABLE>
<form name = "form1" method="post" action="addnews1_.php">
<TABLE cellSpacing=0 cellPadding=2 width="90%" align=center border=1
bgcolor=Azure
bordercolor="#b1ceef">
<TR>
<TD align="left" width="15%">新聞標題:</TD>
<TD width="85%" style="COLOR: #880000"><input name="title" type="text" size = 80/></TD></TR>
<TR>
<TD align="left">日期:</TD>
<TD style="COLOR: #2A0000" ><input name="date" type="text" size = 35/><font size="-4">格式爲:年-月-日,例如2011-6-16</TD></TR>
<TR>
<TD align="left">網址鏈接:</TD>
<TD style="COLOR: #880000"><input name="outlink" type="text" size = 80/></TD></TR>
<TR><TD colspan=2 align="center" >
<input type="submit" name="submit" value="添加" />
</TD></TR>
</TABLE>
</form>
</BODY>
<?php
$tt=$_POST['title'];
$dd=$_POST['date'];
$ll=$_POST['outlink'];
if($tt != '' and $tt != null and $dd != '' and $dd != null and $ll != '' and $ll != null)
{
//require_once 'checkadmin.php';
include 'conn.php';
$exec = "insert into news (date,title,outlink) values ('".$dd."','".$tt."','".$ll."')";
if(mysql_query($exec))
echo "<script>alert('已添加!');location.href='addnews.php';</script>";
else echo "<script>alert('有錯誤,請重新添加!');location.href='addnews.php';</script>";
} else header("location:addnews.php");
?>
<?php
$ii=$_POST['nid'];
$tt=$_POST['title'];
$dd=$_POST['date'];
$ll=$_POST['outlink'];
if($tt != '' and $tt != null and $dd != '' and $dd != null and $ll != '' and $ll != null and $ii != '' and $ii != null)
{
require_once 'checkadmin.php';
include 'conn.php';
$exec = "update news set cfo = 0,ceo = 0, date = '".$dd."',title = '".$tt."',outlink = '".$ll."' where id = ".$ii;
//echo $exec;
if(mysql_query($exec))
echo "<script>alert('已修改!');location.href='mananews.php';</script>";
else echo "<script>alert('有錯誤,請重新修改!');location.href='mananews.php';</script>";
} else header("location:mananews.php");
?>
<?php
$idn=$_GET['nid'];
$web = $_GET['web'];
if($idn != '' and $idn != null)
{
require_once 'checkadmin.php';
include 'conn.php';
if($_SESSION['group'] != 'CFO' and $_SESSION['group'] != 'CEO')
echo "<script>alert('您沒有操作權限,請與管理員聯繫!');location.href='".$web."';</script>";
else {
$exec = "delete from news where id = ".$idn;
//echo $exec;
if(mysql_query($exec))
echo "<script>alert('已刪除!');location.href='".$web."';</script>";
else echo "<script>alert('有錯誤,請重新刪除!');location.href='".$web."';</script>";
}
} else header("location:".$web);
?>