PHP的bbs实现之一

0.sql

CREATE TABLE user_log (
  log_id int(10) NOT NULL auto_increment,
  nicker        varchar(20),
  password varchar(10) NOT NULL,
  log_count  int(10),
  last_time varchar(20),
  last_ip       varchar(30),
  arc_count int(10),
  gender enum('M','W') DEFAULT 'M' NOT NULL,
  level         int(1),
  right         varchar(10),
  exp_count     int(10),
  PRIMARY KEY (log_id),
  UNIQUE log_id (log_id)
);

CREATE TABLE user_attr ( 
  log_id        int(10) NOT NULL,
  realname varchar(20),
  email         varchar(40),
  address varchar(50),
  birthday  varchar(20),
  oicq          int(8),
  last_time varchar(20),
  homepage      varchar(50),
  merriage enum('Y','N') DEFAULT 'N' NOT NULL,
  edu_level varchar(8),
  edu_school    varchar(30),
  province      varchar(20),
  city          varchar(20),
  postalcode    int(6),
  fond          varchar(8), 
  present       text,
  PRIMARY KEY (log_id),
  UNIQUE log_id (log_id)
);

CREATE TABLE user_online (
  log_id int(10) NOT NULL,
  nicker        varchar(20),
  log_count  int(10),
  log_time varchar(20),
  log_ip        varchar(30),
  arc_count int(10),
  gender enum('M','W') DEFAULT 'M' NOT NULL,
  level         int(1),
  right         varchar(10),
  exp_count     int(10),
  PRIMARY KEY (log_id),
  UNIQUE log_id (log_id)
);

1.register.php

<?
  include "common.inc.php";

function Checknicker($nicker) {           
  global $USER_LOG_TABLE;
  $SQL="SELECT nicker FROM $USER_LOG_TABLE WHERE nicker='$nicker'";
  $result=mysql_query($SQL) or die(mysql_error());
  $row=mysql_fetch_Array($result);
  $nicker=$row[nicker];
  return $nicker;
}

function AddUser() {
  global $USER_LOG_TABLE;
  global $id,$REMOTE_ADDR,$nicker;
  global $password, $log_count, $last_time,
          $last_ip, $arc_count, $gender, $level, $right,
          $exp_count;

  $last_time=date("Y:m:d");
  $log_count=0;
  $last_ip=$REMOTE_ADDR;
  $arc_count=0;
  $level=9;                  
  $right='NONE';               
  $exp_count=100;                     
  $SQL="INSERT INTO $USER_LOG_TABLE (
          nicker, password,log_count,last_time,last_ip,arc_count,
          gender,level,right,exp_count) VALUES (
          '$nicker', '$password', '$log_count', '$last_time',
          '$last_ip', '$arc_count', '$gender', '$level', '$right','$exp_count')";

  mysql_query($SQL) or die(mysql_error());
  $SQL="SELECT log_id FROM $USER_LOG_TABLE WHERE nicker='$nicker'";
  $result=mysql_query($SQL) or die(mysql_error());
  $row=mysql_fetch_Array($result);
  $id=$row[log_id];
}                         

if ($Ok) {

  if (!$nicker) $error="用 户 名 不 能 为 空";
  if ((!isset($error)) and (!ereg("[_0-9a-z]*",$nicker))) $error="请 使 用 小 写 字 母"a-z",数 字 "0-9",和 下 划 线 "_"";
  if ((!isset($error)) and (strlen($nicker)<4)) $error="昵称的长度应大于3位";
  if ((!isset($error)) and (Checknicker($nicker))) $error="此 用 户 名 已 存 在";
  if ((!isset($error)) and (!$password)) $error="请 输 入 您 的 密 码";
  if ((!isset($error)) and ($password!=$password2)) $error="两 次 输 入 的 密 码 不 同";
  if (!isset($error)) {
    AddUser();
    header("Location: login_ok.php?id=$id\n");
  } else
  {
    header("Location: login_error.php?error=$error\n");
  }
  exit;
}
include "header.inc.php";
$gender="M"
?>

<BODY>
<TABLE width=100% border=0 align=center>
  <TR class=myBlue>
    <TD height=25 align=center>
        <FONT class=myRed>
         <?echo "用 户 申 请 表"?>
        </FONT>
    </TD>
  </TR>
</TABLE>         

<hr color=red>

<FORM METHOD="POST" ACTION="<? echo $PHP_SELF; ?>">
  <TABLE width=80% border=1  align=center bgcolor=yellow>
    <TR class=myBlack bgcolor=green>
      <TD colspan=2 height=20 align=center>
          <FONT class=myYellow>
             请按照要求填写下列各项!
          </FONT>
      </td>
    </TR>                 
    <TR class=myBlack>
      <TD height=20 width=10% align=center class=myRed>昵 称:</TD>
      <TD height=20 width=72% align=left>
        <INPUT type=text name=nicker maxlength=20 value="<? echo $nicker; ?>" >
        <FONT class=myRed>
        长度不少于4位的字母数字和下划线
        </FONT>
      </TD>
    </TR>
    <TR class=myBlack>
      <TD height=30 width=10% align=center class=myRed>性别:</TD>
      <TD height=30 width=70% align=left>
        <INPUT type=radio name=gender value="M"
           <? echo ($gender=="M") ? "checked" : ""; ?>>
              <font class=myBlue>
                 俊男
              </font>  
        <INPUT type=radio name=gender value="W"
           <? echo ($gender=="W") ? "checked" : ""; ?>>
               <font class=myBlue>
                美女
               </font>
        <FONT class=myRed>            
           当心,别错了!
        </FONT>
      </TD>
    </TR>
    <TR class=myBlack>
      <TD height=30 width=10% align=center class=myRed>
          密    码:
      </TD>
      <TD height=30 width=70%>
        <input type=password name="password" maxlength=8 >
        <FONT class=myRed>
        一定要把它记牢了!进入社区的钥匙!
        </FONT>
      </TD>
    </TR> 
    <TR class=myBlack>
      <TD height=30 width=10% align=center class=myRed>
          重复密码:
      </TD>
      <TD height=30 width=70%>
        <input type=password name="password2" maxlength=8 >
        <FONT class=myRed>
        请再确认一下密码!
        </FONT>
      </TD>
    </TR> 
    <TR class=myBlack>
      <TD height=30 width=80% colspan=2 align=center class=myRed><BR>
        <INPUT type=reset  name=Start value=" 重置 " class=myBlack>                   
        <INPUT type=submit name=Ok value=" 发送 " class=myBlack>                   
        <INPUT type=button name=Back value=" 返回 " class=myBlack
            onClick=JavaScript:history.back()>
      </TD>
    </TR>
  </TABLE>

</FORM>
<DIV class=myGreen align=center>
    <? echo $COPYRIGHT; ?>
</DIV>
<BR>

</BODY>
</HTML> 

2. common.inc

<?                                                                
                                                                  
//数据库所在的主机地址,localhost是本机地址                       
  $MYSQL_HOSTNAME = "localhost";                                  
//数据库登录的用户名称                                            
  $MYSQL_USERNAME = "root";                                       
//数据库登录的密码                                                
  $MYSQL_PASSWORD = "";                                           
//要登录的数据库的名称                                            
  $DATABASE = "goldenwind";                                       
//所有登录的用户名表                                              
  $USER_LOG_TABLE = "user_log";                                   
//用户的详细情况表                                                
  $USER_ATTR_TABLE = "user_attr";                                 
//用户的详细情况表                                                
  $USER_ONLINE_TABLE = "user_online";                             
                                                                  
//显示的版权信息                                                  
  $COPYRIGHT="<BR>Copyright 2000 www.fecit.com, ";         
  $COPYRIGHT.="All Rights Reserved<BR>飞思教育 版权所有!";       
                                                                  
//数据库的连接操作                                                
  mysql_connect($MYSQL_HOSTNAME, $MYSQL_USERNAME, $MYSQL_PASSWORD);
  mysql_select_db($DATABASE) or die(mysql_error());               
                                                                  
?>               

3. login_error.php

<?                                                                           
  include "header.inc.php";                                                  
?>                                                                           
                                                                             
<HTML>                                                                       
<!--HTML的头定义-->                                                          
  <HEAD>                                                                     
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">     
  </HEAD>                                                                    
                                                                             
<BODY>                                                                       
<!--滚动显示提示信息-->                                                      
<marquee scrolldelay="165" class=myYellow bgcolor=green>                     
   欢迎光临金风社区                                      
   这是我们的PHP乐园                                     
   希望您能喜欢它~                                      
</marquee>                                                                   
                                                                             
<!--显示一面迎风飘扬的旗帜作为提示信息-->                                    
<img src="flag.gif" align=left>                                       
<!--显示本页面的大标题-->                                                    
<h2 align=center color=red>                                                  
  错误信息!                                                                 
</h2>                                                                        
<!--显示一条红色的水平的分隔线-->                                            
<hr color=red>                                                               
<!--显示错误信息的提示语句-->                                                
                                                                             
<p align=center>                                                             
     <FONT color=red size=5 align=center>                                    
       <b>                                                                   
              错误信息提示                                   
       </b>                                                                  
     </FONT>                                                                 
</p>                                                                         
                                                                             
<!--显示具体的错误-->                                                        
<p align=center>                                                             
      <FONT color=green size=5 align=center>                                 
         <b>                                                                 
              <?echo"$error"?>                                       
         </b>                                                                
      </FONT>                                                                
</p>                                                                         
                                                                             
<!--显示返回的按钮-->                                                        
<div align=center>                                                           
      <a href="JavaScript:history.back()"><image src="clickme.gif"></a>
</div>                                                                       
                                                                             
</BODY>                                                                      
</HTML>                   

4. login_ok.php     

<?                                                                         
  include "header.inc.php";                                                
?>                                                                         
<!--HTML的头定义-->                                                        
<HTML>                                                                     
<HEAD>                                                                     
   <META http-equiv="Content-Type" content="text/html; charset=gb2312">    
</HEAD>                                                                    
                                                                           
<BODY>                                                                     
<!--滚动显示提示信息-->                                                    
<marquee scrolldelay="165" class=myYellow bgcolor=green>                   
  欢迎光临金风社区                                     
  这是我们的PHP乐园                                    
  希望您能喜欢它~                                     
</marquee>                                                                 
<!--显示一面迎风飘扬的旗帜作为欢迎信息-->                                  
<img src="flag.gif" align=left>                                     
<!--显示本页面的大标题-->                                                  
<h2 align=center color=red>                                                
   金风社区欢迎您!                                                        
</h2>                                                                      
<!--显示一条红色的水平的分隔线-->                                          
<hr color=red>                                                             
<!--显示欢迎信息-->                                                        
<p align=center>                                                           
  <FONT color=red size=5 align=center>                                     
   <b>                                                                     
         您已经成功了!恭喜恭喜                            
   </b>                                                                    
  </FONT>                                                                  
</p>                                                                       
<!--显示欢迎信息-->                                                        
<p align=center>                                                           
  <FONT color=red size=5 align=center>                 , ;                    
   <b>                                                                     
     <?echo"您的标识号是".$id ?>                                           
   </b>                                                                    
  </FONT>                                                                  
</p>                                                                       
<!--提示用户继续进行选择-->                                                
<p align=center>                                                           
   <FONT color=red size=5 align=center>                                    
      <b>                                                                  
          请选择继续或者退回                                       
      </b>                                                                 
   </FONT>                                                                 
</p>                                                                       
<!--对最下面的按钮进行说明-->                                              
<p align=center>                                                           
    <FONT color=green size=4>                                              
      <b>                                                                  
          选择左边的按钮继续登记                                   
      </b>                                                                 
    </FONT>                                                                
    <FONT color=green size=4>                                              
      <b>                                                                  
          选择右边的按钮退回到主界面                               
      </b>                                                                 
    </FONT>                                                                
</p>                                                                       
<!--显示两个动态的按钮-->                                                  
<div align=center>                                                         
      <a href="login.php"><image src="continue.gif" align=center></a>
      <a href="mainform.php"><image src="back.gif"align=center></a> 
</div>                                                                     
</BODY>                                                                    
</HTML>                                                                                                                   

时间: 2024-10-29 10:35:50

PHP的bbs实现之一的相关文章

PHP+HTML简单实现BBS论坛与回帖

        本文主要讲述如何通过PHP+HTML简单实现BBS论坛和发帖/回帖的功能,这是提取我们php项目的部分内容.主要内容包括:         1.通过JavaScript和Iframe实现局部布局界面         2.PHP如何定义类实现访问数据库功能         3.实现简单的BBS论坛和发帖/回帖功能         由于这个项目是十个人在寒假完成,所以采用了SAE搭建在线的后台数据库,其他人在通过Apache本地设计网页.访问数据库的方法实现,相当于简单的BS三端访问

BBS练手JSP系统完成

今天上午,把学习马士兵的BBS系统完事了.本系统主要采用ECLIPSE下WEB项目的开发,JSP,MYSQL,JSP,CSS,JS,html等技术.制作了8个JSP文件,完成了递归(帖子的父子级别).分页.前台后台.树形展现.平板型展现.回复帖子.新建帖子.后台能够管理帖子.删除帖子等操作.   项目可以运行,我将项目源码上传至CSDN,地址如下:   http://download.csdn.net/detail/opzoonzhuzhengke/3881662   下午要做天气预报的文档和部

深度分析:BBS习惯与blog及digg的冲突

BBS习惯与blog及digg的冲突 谁迁就谁? 1顶---BBS里有"顶",我觉得这个"顶"从内涵上要好过digg的"顶",形式上digg的更华丽,为什么这么说呢? 在bbs里的"顶"除了有发布的列表头的功能,它还贡献了内容,而digg只是表达了"好恶".发布到列表头是一种"功利性"的需求,而贡献内容则是自我实现.所以从这个方面来说,我觉得digg是有点哗众取宠. 2列表---BBS玩

基于MySQL的BBS设计(1)

1.系统架构: 采用模块化思想,分为3层: a.数据存储层:使用mysql来存放bbs的所有数据,包括用户信息,文章数据,用户信件,用户消息,系统数据(?),关键问题: 数据库的规划,是否用文件来辅助. b.系统功能层:完成bbs的基本功能,由多个并列模块组成,向下调用mysql的函数访问数据库,向上,接受处理请求,将处理的结果返回上层,根据请求类型,返回成败结果和其他数据.而且模块高度灵活,可以方便的修改增加.包括: ** 用户模块,处理用户的注册,基本数据的修改,权限的变化,网友信息的查询.

使用XML实现BBS

xml <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />  表A: 1-0-1,this is a test 3-1-1,this is a test 4-3-1,this is a test 5-3-1,this is a test 2-0-2,this is a test 上面是BBS主题列表的一个例子.一般来说,假如不是使用Oracle(Oracle 有一条查询语句

动网论坛整合出现/bbs/dv

朋友使用动网8.2整合CMS+OBLOG4.6后,以本地调试一切都正常,结果,上传到服务器空间就无法正常使用了,通过动网论坛登陆时,出现错误,错误提示是: msxml3.dll   错误 '80072ee7'The server name or address could not be resolved }/bbs/dv_dpo/cls_dvapi.asp,行111 通过OBLOG登陆也是提示请求数据出错. 经过分析一下,发布到www.alixixi.com阿里西西网站提供大家参考,解决方法其实

ASP:用ASP打造一个小型的网页BBS系统

传统的网页BBS大多是采用CGI模式实现的,它的实现要求编程者既要掌握编程语言如Perl或C等,又要了解关于CGI模式的各项技术内容,因此要制作自己的网页BBS确实困难不小.ASP(Active Server Pages 动态服务器主页)的出现,使我们眼前一亮,能不能利用ASP实现网页BBS呢?回答当然是肯定的.ASP的诱人之处就在于它提供了一种简单易学的脚本,并带有许多内置的对象,从而提供了一条简捷的编程之路. 该BBS主要由用户注册(浏览器端).用户注册(服务器端).加帖子(浏览器端).加帖

搜索引擎与BBS的母体世界的进化

互联网诞生后的20年中,它的虚拟空间里宛如混沌的宇宙漂浮着若干个简单而又核心的应用,他们分别是电子邮件,FTP,电子公告牌,原始的网络游戏.其中电子公告牌在80年代以后成为互联网诸多创新应用的母体.BBS的各个功能逐渐分离出去成为雄踞一方的霸主.我们先看一下这个母体九个儿子的分离情况(并不以分离时间排序):  第一个:新闻网站是BBS发布新闻功能的演化,这个功能最为简单而且最受用户关注,它应该是BBS踏上独立发展的第一个儿子. 第二个:电子商务是BBS发布供需信息功能的演化.它在演化过程中逐渐与

应对BBS风暴 中小论坛的几条出路

2007年政策突然变化让国内众多BBS措手不及,因为个人申报论坛成功性极低,所以国内大部分中小型论坛面临关闭的危险,对空间服务商和BBS程序开发商将产生较大冲击.建议个人论坛可以考虑以下几个出路: 1.关闭论坛改建网站.这给建站开发商CMS带来无限商机,CMS开发商只要提供帖子转文章的程序,把论坛帖子和图片按对应关系一一转到CMS的文章系统,这将会给CMS带来无限商机! 2.流到国外.利用国外空间建论坛.但是在国外搭论坛速度慢,主要受到出口带宽的限制 3.联合建坛的,个人论坛联合在一起组建公司申

用ASP实现网页BBS

网页 传统的网页BBS大多是采用CGI模式实现的,它的实现要求编程者既要掌握编程语言如Perl或C等,又要了解关于CGI模式的各项技术内容,因此要制作自己的网页BBS确实困难不小.ASP(Active Server Pages 动态服务器主页)的出现,使我们眼前一亮,能不能利用ASP实现网页BBS呢?回答当然是肯定的.ASP的诱人之处就在于它提供了一种简单易学的脚本,并带有许多内置的对象,从而提供了一条简捷的编程之路. 该BBS主要由用户注册(浏览器端).用户注册(服务器端).加帖子(浏览器端)