现在的位置: 首页php-基础语法>正文
php的cms文章删除页面  
发表于600 天前 php-基础语法 评论数 4

cms的文章删除页面与文章编辑页面唯一的不同就是在mysql语句中执行的是delete。

噢,两者还有一点不同:
功能。嘿嘿。

代码如下:

<?php require_once('Connection/conn.php'); ?>
<?php
session_start();
$MM_authorizedUser = "admin";
$MM_donotCheckaccess ="false";
//检查用户是否有权限访问页面
function isAuthorized($strUsers,$strGroups,$UserName,$UserGroup)
{
 $isValid = False;
 if(!empty($UserName))
 {
  $arrUsers = Explode(",",$strUsers);
  $arrGroups = Explode(",",$strGroups);
  if(in_array($UserName,$arrUsers))
  {
   $isValid = true;
  }
  if(in_array($UserGroup,$arrGroups))
  {
   $isValid = true;
  }
  if(($strUsers == " ") && true)
  {
   $isValid = true;
  }
 }
 return $isValid;
}
//检查用户是否已经登录
$MM_restrictGoto = "index.php";
if(!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUser,$_SESSION['MM_Username'],$_SESSION['MM_UserGroup']))))
{
 $MM_qsChar = "?";
 $MM_referrer = $_SERVER['PHP_SELF'];
 if(strpos($MM_restrictGoto,"?"))
 {
  $MM_qsChar = "&";
 }
 if(isset($QUERY_STRING) && strlen($QUERY_STRING)>0)
 $MM_referrer .= "?".$QUERY_STRING;
 $MM_restrictGoto = $MM_restrictGoto.$MM_qsChar."accesscheck=".urlencode($MM_referrer);
 header("Location: ".$MM_restrictGoto);
 exit;
}
//查询文章类型
mysql_select_db($database_conn,$conn);
$query_rs_types = "select * from types order by type_id asc";
$rs_types = mysql_query($query_rs_types,$conn)
or die(mysql_error());
$row_rs_types = mysql_fetch_asso($rs_types);
$totalRow_rs_types = mysql_num_rows($row_rs_types);
//查询网站配置
mysql_select_db($database_conn,$conn);
$query_rs_config = "select $ from config,templates where config.templates_id = templates.template_id";
$rs_config = mysql_query($query_rs_config)
or die(mysql_error());
$row_rs_config = mysql_fetch_assoc($rs_config);
$totalRow_rs_config = mysql_num_rows($row_rs_config);
//转换用户输入的字符串
function GetSQLValueString($theValue,$theType,$theDefinedValue=" ",$theNotDefinedValue = "")
{
 $theValue = (!get_magic_quotes_gpc())?addslashes($theValue):$theValue;
 switch($theType)
 {
  case "text":
   $theValue = ($theValue != "")?"'".$theValue."'":"NULL";
   break;
  case "int":
   $theValue = ($theValue != "")?intval($theValue):"NUll";
   break;
 }
 return $theValue;
}
//执行文章删除操作
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if((isset($_POST["MM_insert"])) && ($_POST["MM_insert"]=="form1"))
{
 $deleteSQL = sprintf("delete from articles where article_id = %s",
    GetSQLValueString($_POST['article_id'],"int")
 );
 mysql_select_db($database_conn,$conn);
 $Result = mysql_query($deleteSQL,$conn)
 or die(mysql_error());
 $deleteSQLGoTo = "admin_list.php";
 header(sprintf("Location: %s",$deleteSQLGoTo)); 
}
//如果网站关闭了怎么办
if($row_rs_config['available_indc'] ==0)
{
 die("www.phpdo.net维护中,请稍后访问");
}
//调用模板文件
include('templates\\'.$row_rs_config['folder_name'].'\\send.inc.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=gb2312" />
<title>编辑文章</title>
<style>
<!--
.style1 {font-size:18px;
font-weight:bold;
}
.style4 {font-size:12px;
}
-->
</style>
</head>

<body>
<form method="post" action="<?php echo $editFormAction;?>">
<table  align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">文章标题:</td>
<td><div align="left"><input value="<?php echo $row_rs_articles['title'];?>" size="32"></div></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">文章内容</td>
<td><textarea cols="50" rows="10">
<?php echo $row_rs_articles['content'];?></textarea></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">文章类别</td>
<td>
<div align="left">
<p>
<select>
<?php do {?>
<option value="<?php echo $row_rs_articles['type_id']?>" <?php if($row_rs_types['type_id'] == $row_rs_articles['type_id']){echo "selected";}?>><?php echo $row_rs_types['type_name'];?></option>
<?php }
while($row_rs_types = mysql_fetch_assoc($rs_types));
$rows = mysql_num_rows($rs_types);
if($rows > 0)
{
 mysql_data_seek($rs_types,0);  //这句话是什么意思?--------------------------
 $row_rs_types = myql_fetch_assoc($rs_types);
}
?>
</select>
</p>
</div>
</td>
</tr>
<tr valign="baseline">
<td align="center" colspan="2" nowrap="nowrap">
<div align="center">
<input value="提交">
<input value="重置">
</div>
</td>
</tr>
</table>
<input value="form1">
<input value="<?php echo $row_rs_types['article_id'];?>"></input> //存储当前的articles_id
</form>
<p>&nbsp;&nbsp;</p>
</body>
</html>
<?php
//关闭数据库连接
mysql_free_result($rs_types);
mysql_free_result($rs_types);
?>

php的cms文章删除页面:目前有4 条留言

  1. 学夫子 : 2010年09月29日5:29 下午

    这个,懒得深入研究了,呵呵,支持一个,预祝博主国庆愉快

    老张 回复:

    @学夫子, 同快同快,爱好PHP,所以学学

  2. 卢松松 : 2010年09月29日8:46 下午

    这就是网站开发吧

    老张 回复:

    @卢松松, 对,我对网站开发这方面的兴趣比较大。。

不想听你唠叨×