社区源代码(php&mysql)之五
//以下为writing.php文件(此页面用于发表文章)
<?
  
include "../inc/sql.inc.php";
  include 
"../inc/header.inc";


           
$sql="select * from online where id='$id'";
              
$result=mysql_query($sql);
           
$row=mysql_fetch_array($result) ;
           
$writer=$row["userid"];
           
    if(
$ok){
        if(empty(
$title)||empty($content)){
             
$error=3;
            
header("Location:../error.php?error=$error");
        }

        
          else{
           
$sql="select title from bbs where title='$title'";
           
$result=mysql_query($sql);
           
$count=mysql_num_rows($result);

             if(
$count>0){        //判断是否有相同标题的文章
                
$error=4;
                
header("Location:../error.php?error=$error");
             }

             else{
               
$sql="select * from user_attr where userid='$writer'";
               
$result=mysql_query($sql);
               
$row=mysql_fetch_array($result) ;

               
$exper_cent=$row["exper_cent"];
               
$money=$row["money"];
           
               
$exper_cent+=5;
               
$money+=10;
           
               
$sql="update user_attr set exper_cent='$exper_cent',money='$money' where userid='$writer'";
               
mysql_query($sql);

               
$size=strlen($content);
               
$writetime=time();
               
$mainid=$writetime;
               
$bbsid=$mainid;


           
               
$sql="INSERT INTO bbs (bbsid,mainid,blockid,mood,title,content,size,writer,writetime) 
               VALUES ('$bbsid','$mainid','$bbstitle','$mood','$title','$content','$size','$writer','$writetime')"
;
               
mysql_query($sql);

           
               
header("Location:bbstxt.php?id=$id&bbstitle=$bbstitlen");
               exit;
             }
          }
          
  
  }

?>
<html>
<head>
<title>WRITING</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
   td{font-size:9pt}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
 <div id="layer1" style="position:absolute; left:0px;top:10px; z-index:1"> 
<TABLE width=100% border=0 align=center>
  <TR class=wdBlack>
    <TD width=25%>  版主:<? echo $id,$bbstitle ?> </TD>
    <TD width=50%>讨论区: <FONT color=red></FONT></TD>
    <TD width=25% align=center><FONT color=#2F8BDF>●</FONT> 发表文章</TD>
  </TR>
</TABLE>

<HR color=#E3E3E3 noshade width=100% size=1>
</div>
<div id="layer2" style="position:absolute; left:10px;top:30px; z-index:1"> 
<FORM name=AddForm method=POST action="writing.php?bbstitle=<? echo $bbstitle?>">
  <TABLE width=95% border=0 cellpadding=2 cellspacing=2 align=center>
    <TR>
      <TD height=20>&nbsp;</td>
    </TR>
    <TR>
      <TD height=32>主题: <INPUT type=text name=title size=30 maxlength=30> <FONT color=red>*</FONT></TD>
   
    </TR>
    <TR></TR>
    <tr>
      <TD width=70%>
        <TEXTAREA name="content" cols=50 rows=10 wrap=hard></TEXTAREA>
      </TD>
      <TD width=30%>
        <TABLE width=80% border=0 align=right>
          <TR>
            <TD width=68>
              <INPUT type=radio value=0 name="mood" checked><IMG src=../image/mood0.gif width=15 height=15 alt=" 心情不错!">
            </TD>
            <TD width=68>
              <INPUT type=radio value=1 name="mood"><IMG src=../image/mood1.gif width=15 height=15 alt=" 随便说说... ">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=2 name="mood"><IMG src=../image/mood2.gif width=15 height=15 alt=" 谁来帮助我?">
            </TD>
            <TD width=68>
              <INPUT type=radio value=3 name="mood"><IMG src=../image/mood3.gif width=15 height=15 alt=" 呜呜~~我好伤心!">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=4 name="mood"><IMG src=../image/mood4.gif width=15 height=15 alt=" 哼!气死我了!">
            </TD>
            <TD width=68>
              <INPUT type=radio value=5 name="mood"><IMG src=../image/mood5.gif width=15 height=15 alt=" 嘻嘻,开心!">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=6 name="mood"><IMG src=../image/mood6.gif width=15 height=15 alt=" 对面的人儿看过来... ">
            </TD>
            <TD width=68>
              <INPUT type=radio value=7 name="mood"><IMG src=../image/mood7.gif width=15 height=15 alt=" 当心!!!">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=8 name="mood"><IMG src=../image/mood8.gif width=15 height=15 alt=" 同意!">
            </TD>
            <TD width=68>
              <INPUT type=radio value=9 name="mood"><IMG src=../image/mood9.gif width=15 height=15 alt=" 我反对!">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=10 name="mood"><IMG src=../image/mood10.gif width=15 height=15 alt=" 号外!号外!">
            </TD>
            <TD width=68>
              <INPUT type=radio value=11 name="mood"><IMG src=../image/mood11.gif width=15 height=15 alt=" 我来回答你!">
            </TD>
          </TR>
          <TR>
            <TD width=68>
              <INPUT type=radio value=12 name="mood"><IMG src=../image/mood12.gif width=15 height=15 alt=" 咦?奇怪!">
            </TD>
            <TD width=68>
              <INPUT type=radio value=13 name="mood"><IMG src=../image/mood13.gif width=15 height=15 alt=" 不知所云... ">
            </TD>
          </TR>
        </TABLE>
      </TD>
    </TR>
    <TR>
      <TD>     
        <INPUT type=submit name=ok value=" 发送 " >                   
        <INPUT type=button name=Back value=" 返回 " onClick=JavaScript:history.back()>
        <INPUT type="hidden" name="id" value="<? echo $id?>">
        <INPUT type="hidden" name="blockid" value="<? echo $bbstitle?>">
      </TD>
    </TR>
  </TABLE>
</FORM>
</div>
<div id="layer3" style="position:absolute; left:0px;top:300px; z-index:1">
<?
include "../inc/copyright.inc";
?>
</div>
</body>
<html>