首頁 > 後端開發 > php教程 > 基於mysql的論壇(3)_PHP教程

基於mysql的論壇(3)_PHP教程

WBOY
發布: 2016-07-21 16:02:57
原創
1022 人瀏覽過

#####################
# func.php #########
########## ##########
require("config.inc.php");
####檢查使用者是否存在#####
function is_user_exits($name) {
         $name=trim($name);
         $name ($name);
         $SQL="從使用者選擇名稱WHERE name='$name'";
         $result=my fetch_Array($result );
         $name=$row[name];
          $name=$row[name];
         返回$名稱中;
}
#########ex;>p. baord){
         $sql="select name from boardinfo where name='$baord'" ;
         $row=mysql_fetch_array ($result);
         $name=$row[name];
         返回$名稱;
}
####添加新用戶Function #####
function adduser( ){
         global $name,$sex,$realname,$password,$address,$oicq ,$首頁,$電話,$電子郵件,$qm,$regtime );
         $name=ereg_replace("'","'",$name);
         🎜>         $ realname=htmlspecialchars($realname);
         $address=htmlspecialchars($address);
       htmlspecialchars($homepage);
         $phone= htmlspecialchars($phone);
         $email=htmlspecialchars($email);
        m-d H:i:s");
         $sql="插入使用者(姓名、性別、真實姓名、密碼、地址、oicq、首頁、分數、電話、電子郵件、qm、regtime、slaveboard)值('$name','$sex',' $ realname','$password','$address','$oicq','$homepage','0','$phone','$email','$qm','$regtime','' ) 」;
         mysql_query($sql) 或die(mysql_error());
}
####### URL 重新導向2($###
         header("Location:$url");
}
######建立版面######
function create_board_table($name,$name,$name) {
function create_board_table($name,$> $name=trim("$name");
         $sql="CREATE TABLE $name(id int(11) NOT NULL AUTO_INCRMENT,title varchar(50) NOT NULL,writer varcharULLed NOTtext , size int,writetime varchar(20) NOT NULL ,命中int(4) 預設'0',good varchar(1),renum int(4) 預設'0',slaveid int(11) 預設'0',fromip varchar (15),PRIMARY KEY (id))" ;
         mysql_query($sql);
         $sql="插入板info(name,chinchinname)          mysql_query($sql);
}
###### 移除版面######
function drop_board_table($name){ ";
         mysql_query($sql);
         $sql="從boardinfo 🎜>## ###### 修改版面###
function update_board($name,$chinesename) {
    $sql="update boardinfo set name='$name', chinesename='$chinesename'sname' name'name=sname= '$name'";
    mysql_query($sql);
}
####新增文章######
function add_doc($board){
         global $title,$name,$cont,$writer,$fromip,$fromip,$fromipqm,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromip,$fromipm) $new_topic_score;
         $title=trim($title);
         $title=substr($title,0,49);
         $size=strlen($cont);
         $cont=htmlencode2($cont);
         $cont=$cont."
"."--------
".$qm;
         $writetime=date("Y-m-d H:i:s");
         $fromip=getenv("remote_addr");
         $name=htmlspecialchars($name);
         $writer=$name;
         $sql="插入$board (標題,writer,cont,size,writetime,fromip) Value('$title','$name','$cont','$size','$writetime' , '$fromip')";
         mysql_query($sql);
         add_score($writer,$new_topic_score);
}
###### 回覆文章 ####
function re_doc($board,$slaveid){
         global $title,$name,$cont,$wter    global $title,$name,$con,$f fromip ,$writetime,$qm,$re_topic_score;
         $title=trim($title);
         $title=substr($title,0,49);
         $size=strlen($cont);
         $cont=htmlencode2($cont);
         $cont=$cont."
"."--------
".$qm;
         $writetime=date("Y-m-d H:i:s");
         $name=htmlspecialchars($name);
         $writer=$name;
         $fromip=getenv("remote_addr");
         $sql="插入$board(標題,writer,cont,size,writetime,slaveid,fromip) 值('$title','$writer','$cont','$size','$ writetime','$ writetime','$ write ','$slaveid','$fromip')";
         mysql_query($sql);
         $sql="update $board set renum=renum 1 where id=$slaveid";
         mysql_query($sql);
         add_score($writer,$re_topic_score);
}
###### 刪除文章 ####
function del_doc($board,$id){
         global $remove_score;
         $sql="select * from $board where id=$id";
         $sql_result=mysql_query($sql);
         $sql_row=mysql_fetch_array($sql_result);
         $writer=$sql_row[writer];
         remove_score($writer,$remove_score);
         $slaveid=$sql_row[slaveid];
         $sql="select * from $board where id=$slaveid";
         $sql_result=mysql_query($sql);
         $sql_row=mysql_fetch_array($sql_result);          
         if ($sql_row[renum]>0){
             
              mysql_query($sql);
         }
         $sql="從$board刪除,其中id=$id";
         mysql_query($sql);
         $sql="從$board中移除,其中Slaveid=$id";
         mysql_query($sql);
}
#### 轉換html 特殊字元與
#####
函數htmlencode2($str){
         $str ial $str);
         回傳$str;
}
###### 增加一個點選####
function add_one_hit($board,$id){ function add_one_hit($board,$id){ function c "update $board set attempts=hits 1 where id= $id";
         mysql_query($sql);
}
#unc###user_passfunc#(c#>#); $name,$password){
         $name=trim($name);
         $name=ereg_replace("'","'",$name);
         $name=htmlspecialchars($name) ;
         $password=trim($password);
         $sql="從名稱='$name'的使用者中選擇密碼>         $ sql_row=mysql_fetch_array($sql_result);
         if($password>>$sql_row[password]){
      }
         其他{
              $結果中=1;
              setcookie ("jl_forum[name]",$name);
            }
         返回$結果;
}
# ####檢查管理員密碼####
function check_admin_password(){
         $sql="select * from user where name='$jl_forum[name]'" ;          $sql_row=mysql_fetch_array($sql_result);
         $result=1;
        }
        其他{
            $結果=0;
       🎜>            $result=1;
        }
         }
        {
            $結果=0;
        }  
   
function change_profile($name ){
         global $sex,$realname,$password,$address,$oicq ,$首頁,$電話,$電子郵件,$qm;
  $ $ name=htmlspecialchars($name);
         $realname=htmlspecialchars($realname);
        chars($oicq);
         $homepage= htmlspecialchars($homepage);
         $phone=htmlspecialchars($phone);
         $qm);
         $sql="更新使用者設定sex='$sex',realname='$realname',password='$password',address='$address',oicq='$oicq',homepage='$homepage ',phone='$phone' ,email='$email',qm='$qm' 其中name='$name'";
         mysql_query($sql);
}
##### 顯示錯誤####
function show_error($id){
         redirect2("wrong.php?id=$id");
}
# ### 增加版主####
function add_admin($board,$name){
         $name=trim($name);
 ' where name='$name'";
         mysql_query($sql);
}
###### 刪除版主#####
function del_admin(name){name) 🎜>         $name=trim($name);
         $name=htmlspecialchars($name);          mysql_query ($sql);
}
##### 貼子轉精華####
function set_good($board,$id){
        ='y' where id=$id";
         mysql_query($sql);
}
##### 轉出精華###
function set_n. {
         $sql="update $board set good='' where id=$id";
         #
function expl_qm($name){
        $name=htmlspecialchars($name);
       $sql_result=mysql_query ($sql);
         $sql_row=mysql_fetch_array($sql_result);
         }
##### 管理員#####
function adminok() {
    if ($jl_admin[name]==$admin_name and $jl_admin[password]==$admin_password) {     else {
        return 0;
    }
}
# #($ name=htmlspecialchars($name);
    $sql="update user set score=score $num where name='$name'";
    mysql_query($);
; ### 減少積分####
function remove_score($name,$num) {
    $name=htmlspecialchars($name);
    $sql="update user where name='$name'";
    mysql_query($sql);
}
#### 留言#####
function sendmsg() {
$name,$cont;
    $name=htmlspecialchars($name);
    $fromname=htmlspecialchars($fromname);
   =$cont= "Y-m-d H:i:s");
    $sql="insert into message (name,fromname,cont,writetime) values ('$name','$fromname','$cont','$wt' )";
    mysql_query($sql);
}
#### 刪除留言####
function delmsg($id) {
from$   id=$id";
    mysql_query($sql);
}
### 留言是否屬於這個人######
function is_this_user($id) {  ="select name from message where id=$id";
    $sql_result=mysql_query($sql);
    $sql_row=mysql_fetch_row($fresult);         return 1;
    }
    else {  ) ?>
##########################
# good.php ##########
########################
    require("func.php");
    $sql="select * from boardinfo";
    $sql_result=mysql_query($sql);
?>


main






  
  
    

      
璁哄

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板