经典初级的CMS

<?php session_start(); if($action=='logout'){ session_unset(); session_destroy(); ?> <mce:script language="javascript"><!-- alert("已注销"); location.href="index.php"; // --></mce:script> <?php }elseif($_SESSION['uid']) { if($op=='edittype'&&$_POST[typename]&&$_POST[tid]) { include("include/conn.php"); $query="update type set typename='".$_POST[typename]."' where tid='".$_POST[tid]."'"; $info=mysql_query($query); echo "<mce:script language=/"javascript/"><!-- alert(/"类型名已更改/"); location.href=/"adminop.php?action=type/"; // --></mce:script>"; exit(); } elseif($op=='deltype'&&$tid) { include("include/conn.php"); $query="select count(*) ct from content where tid='".$tid."'"; $info=mysql_query($query); while($result=mysql_fetch_array($info,MYSQL_ASSOC)){ if($resutl[ct]!=0) { echo "<mce:script language=/"javascript/"><!-- alert(/"有主题的分类无法删除,请先删除分类下的主题!/"); location.href=/"adminop.php?action=type/"; // --></mce:script>"; mysql_close($connection); exit(); } } $query="delete from type where tid='".$tid."'"; $info=mysql_query($query); mysql_close($connection); echo "<mce:script language=/"javascript/"><!-- alert(/"删除类别成功!/"); location.href=/"adminop.php?action=type/"; // --></mce:script>"; exit(); } elseif($op=='newtype'&&$_POST[newtype]) { include("include/conn.php"); $query="insert into type set typename='".$_POST[newtype]."'"; $info=mysql_query($query); echo "<mce:script language=/"javascript/"><!-- alert(/"新建类别成功!/"); location.href=/"adminop.php?action=type/"; // --></mce:script>"; mysql_close($connection); exit(); } elseif($op=='delcontent'&&$cid) { include("include/conn.php"); $query="delete from content where cid='".$cid."'"; $info=mysql_query($query); echo "<mce:script language=/"javascript/"><!-- alert(/"删除内容已成功/"); location.href=/"adminop.php?action=content/"; // --></mce:script>"; mysql_close($connection); exit(); } include("include/top.php"); ?> <div id="content"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15%" style="BORDER-RIGHT:#d2d2d2 1px solid;BORDER-TOP:#d2d2d2 1px solid" mce_style="BORDER-RIGHT:#d2d2d2 1px solid;BORDER-TOP:#d2d2d2 1px solid" vAlign=top width=180 height="100%"> <table cellSpacing=0 cellPadding=4 width="100%" align=center border=0> <tr><td colspan=3 background="images/menu_top.gif"> </td></tr> <tr><td> </td> <td colSpan=2 align="left"><b style="FONT-SIZE:16px;COLOR:#0066cc" mce_style="FONT-SIZE:16px;COLOR:#0066cc">内容分类:</b></td></tr> <tr> <td> </td><td align=right width="16%"><IMG src="images/arrow4.gif" mce_src="images/arrow4.gif"></td> <td align="left"><a href="adminop.php?action=type" mce_href="adminop.php?action=type">分类管理</a></td></tr> <tr> <td> </td><td align=right width="16%"><IMG src="images/arrow4.gif" mce_src="images/arrow4.gif"></td> <td align="left"><a href="adminop.php?action=content" mce_href="adminop.php?action=content">内容管理</a></td> </tr> <tr> <td> </td><td align=right width="16%"><IMG src="images/arrow4.gif" mce_src="images/arrow4.gif"></td> <td align="left"><a href="adminop.php?action=newcontent" mce_href="adminop.php?action=newcontent">发布内容</a></td> </tr> <tr> <td> </td><td align=right width="16%"><IMG src="images/arrow4.gif" mce_src="images/arrow4.gif"></td> <td align="left"><a href="adminop.php?action=logout" mce_href="adminop.php?action=logout">退出系统</a></td> </tr> </table> </td> <td align="center" valign="top" width="80%"> <?php if($action=='type') { include("include/conn.php"); $query="select * from type"; $info=mysql_query($query); $typearr=array(); while($result=mysql_fetch_array($info)) { $typearr[]=$result; } ?>分类管理: <table width="90%" border="2" cellspacing="1" cellpadding="0"> <tr> <td>类别ID</td> <td>类别名</td> <td>操作</td> </tr> <?php foreach($typearr as $type) { echo "<form action=/"adminop.php?op=edittype/" method=/"post/"> <input type=/"hidden/" name=/"tid/" value=/"$type[tid]/"/> <tr> <td>$type[tid]</td> <td><input type=/"text/" name=/"typename/" value=/"$type[typename]/"></td> <td><input type=/"submit/" value=/"修改/"><input type=/"submit/" value=/"删除/" onclick=if(confirm(/"确定删除?/")){location.href=/"adminop.php?op=deltype&tid=$type[tid]/";}></td> </tr></form> "; } ?> </table><br/> <form action="adminop.php?op=newtype" method="post"> <table width="90%" border="2" cellspacing="1" cellpadding="0"> <tr> <td width="30%">新建类别</td> <td width="50%"><input type="text" value="" name="newtype" /></td> <td width="20%"><input type="submit" value="新建类别" /></td> </tr> </table> </form> <?php } elseif(action=='content'){ include("include/conn.php"); $query="select * from content"; $info=mysql_query($query); $contentarr=array(); while($result=mysql_fetch_array($info,MYSQL_ASSOC)){ $result[dateline]=date("Y-m-d",$result[dateline]); $contentarr[]=$result; }?>内容管理:<br/><br/> <table width="90%" border="2" cellspacing="1" cellpadding="0"> <tr> <td width="10%">类别ID</td> <td width="50%">主题</td> <td width="10%">发布人</td> <td width="15%">时间</td> <td width="15%">操作</td> </tr> <?php foreach($contentarr as $content) { echo"<tr><td>$content[tid]</td> <td>$content[subject]</td> <td>$content[author]</td> <td>$content[time]</td> <td><input type=/"button/" value=/"修改/" onclick=if(confirm(/"确定修改?/")){location.href=/"adminop.php? op=editcontent&cid=$content[cid]/";} />  <input type=/"button/" value=/"删除/" onclick=if(confirm(/"确定删除?/")){location.href=/"adminop.php? op=delcontent&cid=$content[cid]/";} /></td> </tr>"; } ?> </table><br/> <br/> <br/> <br/> <?php } elseif($action=='newcontent') { include("include/conn.php"); $query="select * from type"; $info=mysql_query($query); $typearr=array(); while($result=mysql_fetch_array($info,MYSQL_ASSOC)){ $typearr[]=$result; } ?> <p>发布内容</p> <br/> <br/> <form action="post.php" method="post"> <div align="center" width="90%"> <table width="90%" border="2" cellspacing="1" cellpadding="1"> <tr> <td width="15%">类别选择:</td> <td> <select name="type" value="type"> <?php foreach($typearr as $type) { echo "<option value=/"$type[tid]/">$type[typename]</option>"; } ?> </select> </td> </tr> <tr> <td width="15%">标题:</td> <td><input type="text" name="subject" id="subject" size="80" /></td> </tr> <tr> <td width="15%" valign="top">内容:</td> <td><textarea name="message" rows="20" cols="80" id="message" >

修改内容:

类别选择
标题
内容 <?php echo $content[message];? >

"; exit(); } include("include/conn.php"); $query="select * from admin where username='".$_POST[username]."' and passwd='".$_POST[passwd]."'"; $info=mysql_query($info); if($result=mysql_fetch_array($info,MYSQL_ASSOC)) { $_SESSION[uid]=$result[uid]; $_SESSION[username]=$result[username]; } else{ echo " "; exit(); }?>

CMS管理系统后台管理登录

   
管理员账号:
   
管理员密码:
    

你可能感兴趣的:(mysql,cms,query,action,include,border)