程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php 添加文章

php 添加文章

編輯:關於PHP編程

<?php 
/**
 * 添加文章
 * 2011/8/21
 * kcj
 * */ 
include "isLogin.php"; 
include "../FCKeditor/fckeditor.php"; 
include "../conn/conn.php"; 
$FCKeditor=new FCKeditor("content"); 
$FCKeditor->BasePath = '../FCKeditor/'; 
$title=$_POST['title']; 
$url=$_POST['url']; 
$zhaiyao=$_POST['zhaiyao']; 
$author=$_POST['author']; 
$laiyuan=$_POST['laiyuan']; 
$keyword=$_POST['keyword']; 
$content=$_POST['content']; 
if(isset($_POST['action'])!=''&&$_POST['action']="add"){ 
  $sql="insert into article (title,url,zhaiyao,author,laiyuan,keyword,content,ctime) values  
    ('".$title."','".$url."','".$zhaiyao."','".$author."','".$laiyuan."','".$keyword."','".$content."',now())"; 
    mysql_query($sql); 
    echo "文章添加成功"; 

?> 
 
 
<html> 
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
        <title>無標題文檔</title> 
        <meta name="Author" content="kcj" /> 
        <meta name="Keywords" content="php,lampbrother" /> 
        <link rel="stylesheet" type="text/css" href="style/lampcms.css"> 
        <script src="javascript/common.js"></script> 
        <script type="text/javascript"> 
        function vaArticle(article){ 
            if(article.title.value==''){ 
                alert("文章標題不能為空"); 
                article.title.focus(); 
                return false; 
            } 
            if(article.zhaiyao.value==''){ 
                alert("文章摘要不能為空"); 
                article.zhaiyao.focus(); 
                return false; 
            } 
            if(article.author.value==''){ 
                alert("文章作者不能為空"); 
                article,author.focus(); 
                return false; 
            } 
            if(article.keyword.value==''){ 
                alert("文章關鍵字不能為空"); 
                article.keyword.focus(); 
                return false; 
            } 
            if(article.content.value.length>20){ 
                alert("文章內容不能少於20個字"); 
                article.content.focus(); 
                return fasle 
            } 
        } 
         
        </script> 
    </head> 
    <body> 
        <div id="main"> 
             後台管理->添加文章 
            <form name="article" method="post" action="" onsubmit="return vaArticle(this)"> 
             
            <div class="msg-box"> 
                <ul class="viewmess"> 
                    <li class="light-row"> 
                        <span class="col_width">添加文章</span> 
                         
                    </li> 
                    <li class="dark-row"> 
                        <span class="col_width">文章標題 <span class="red_font">*</span></span> 
                        <input type="text" class="text-box" name="title" size="30"  maxlength="40"> 
                    </li> 
                    <li class="light-row"> 
                        <span class="col_width">文章來源URL<span class="red_font">*</span></span> 
                        <input type="text" class="text-box" name="url" size="30" >  如自己更改請注意格式.沒有可以不填 
                    </li> 
                    <li class="dark-row"> 
                        <span class="col_width" style="margin-top:25px">文章摘要</span> 
                        <textarea class="text-box" name="zhaiyao" cols="40" rows="4"></textarea>  小於100個漢字. 
                    </li> 
                    <li class="light-row"> 
                        <span class="col_width">文章作者 <span class="red_font">*</span></span> 
                        <input type="text" class="text-box" name="author" size="15"  maxlength="20"> 
                    </li> 
                    <li class="dark-row"> 
                        <span class="col_width">文章來源</span> 
                        <input type="text" class="text-box" name="laiyuan" size="25"  maxlength="25"> 
                    </li> 
                    <li class="light-row"> 
                        <span class="col_width">關鍵字   <span class="red_font">*</span></span> 
                        <input type="text" class="text-box" name="keyword" size="25" maxlength="20">  用於文章搜索,多個請用逗號","隔開. 
                    </li> 
                    <!--<li class="dark-row"> 
                        <span class="col_width">是否推薦</span> 
                        <input type="radio" name="recommend"  value="1"> 推薦 
                        <input type="radio" name="recommend" value="0"> 不推薦 
                    </li>--> 
                    <li style="margin:0px; padding:0px"> 
                        <?php   echo $FCKeditor->Create(); ?> 
                    </li> 
     
                    <li class="dark-row"> 
                        <span class="col_width">   </span> 
                        <input type="hidden" name="action" value="add"> 
                        <input type="submit" class="button" name="mod" value="添加">   
                        <input type="reset" class="button" value="重 置"> 
                    </li> 
                </ul>  
            </div> 
                    </form>    
        </div> 
    </body> 
</html> 
<?php
/**
 * 添加文章
 * 2011/8/21
 * kcj
 * */
include "isLogin.php";
include "../FCKeditor/fckeditor.php";
include "../conn/conn.php";
$FCKeditor=new FCKeditor("content");
$FCKeditor->BasePath = '../FCKeditor/';
$title=$_POST['title'];
$url=$_POST['url'];
$zhaiyao=$_POST['zhaiyao'];
$author=$_POST['author'];
$laiyuan=$_POST['laiyuan'];
$keyword=$_POST['keyword'];
$content=$_POST['content'];
if(isset($_POST['action'])!=''&&$_POST['action']="add"){
  $sql="insert into article (title,url,zhaiyao,author,laiyuan,keyword,content,ctime) values
 ('".$title."','".$url."','".$zhaiyao."','".$author."','".$laiyuan."','".$keyword."','".$content."',now())";
 mysql_query($sql);
    echo "文章添加成功";
}
?>


<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  <title>無標題文檔</title>
  <meta name="Author" content="kcj" />
  <meta name="Keywords" content="php,lampbrother" />
  <link rel="stylesheet" type="text/css" href="style/lampcms.css">
  <script src="javascript/common.js"></script>
  <script type="text/javascript">
  function vaArticle(article){
   if(article.title.value==''){
    alert("文章標題不能為空");
    article.title.focus();
    return false;
   }
   if(article.zhaiyao.value==''){
    alert("文章摘要不能為空");
    article.zhaiyao.focus();
    return false;
   }
   if(article.author.value==''){
    alert("文章作者不能為空");
    article,author.focus();
    return false;
   }
   if(article.keyword.value==''){
    alert("文章關鍵字不能為空");
    article.keyword.focus();
    return false;
   }
   if(article.content.value.length>20){
    alert("文章內容不能少於20個字");
    article.content.focus();
    return fasle
   }
  }
  
  </script>
 </head>
 <body>
  <div id="main">
       後台管理->添加文章www.2cto.com
      <form name="article" method="post" action="" onsubmit="return vaArticle(this)">
   
   <div class="msg-box">
    <ul class="viewmess">
     <li class="light-row">
      <span class="col_width">添加文章</span>
      
     </li>
     <li class="dark-row">
      <span class="col_width">文章標題 <span class="red_font">*</span></span>
      <input type="text" class="text-box" name="title" size="30"  maxlength="40">
     </li>
     <li class="light-row">
      <span class="col_width">文章來源URL<span class="red_font">*</span></span>
      <input type="text" class="text-box" name="url" size="30" >  如自己更改請注意格式.沒有可以不填
     </li>
     <li class="dark-row">
      <span class="col_width" style="margin-top:25px">文章摘要</span>
      <textarea class="text-box" name="zhaiyao" cols="40" rows="4"></textarea>  小於100個漢字.
     </li>
     <li class="light-row">
      <span class="col_width">文章作者 <span class="red_font">*</span></span>
      <input type="text" class="text-box" name="author" size="15"  maxlength="20">
     </li>
     <li class="dark-row">
      <span class="col_width">文章來源</span>
      <input type="text" class="text-box" name="laiyuan" size="25"  maxlength="25">
     </li>
     <li class="light-row">
      <span class="col_width">關鍵字   <span class="red_font">*</span></span>
      <input type="text" class="text-box" name="keyword" size="25" maxlength="20">  用於文章搜索,多個請用逗號","隔開.
     </li>
     <!--<li class="dark-row">
      <span class="col_width">是否推薦</span>
      <input type="radio" name="recommend"  value="1"> 推薦
      <input type="radio" name="recommend" value="0"> 不推薦
     </li>-->
     <li style="margin:0px; padding:0px">
      <?php   echo $FCKeditor->Create(); ?>
     </li>
 
     <li class="dark-row">
      <span class="col_width">   </span>
      <input type="hidden" name="action" value="add">
      <input type="submit" class="button" name="mod" value="添加"> 
      <input type="reset" class="button" value="重 置">
     </li>
    </ul> 
   </div>
                    </form> 
  </div>
 </body>
</html>


摘自 chaojie2009的專欄

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved