首页 > 开发 > PHP > 正文

PHP的bbs实现之一

2024-05-04 22:59:26
字体:
来源:转载
供稿:网友

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>            
          &nbsp当心,别错了!
        </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 &copy; 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>                     
   欢迎光临金风社区&nbsp&nbsp&nbsp&nbsp&nbsp                                 
   这是我们的php乐园&nbsp&nbsp&nbsp&nbsp&nbsp                                
   希望您能喜欢它~&nbsp&nbsp&nbsp&nbsp&nbsp                                 
</marquee>                                                                   
                                                                             
<!--显示一面迎风飘扬的旗帜作为提示信息-->                                    
<img src="http://www.pushad.com/info/images/flag.gif" align=left>                                       
<!--显示本页面的大标题-->                                                    
<h2 align=center color=red>                                                  
  错误信息!                                                                 
</h2>                                                                        
<!--显示一条红色的水平的分隔线-->                                            
<hr color=red>                                                               
<!--显示错误信息的提示语句-->                                                
                                                                             
<p align=center>                                                             
     <font color=red size=5 align=center>                                    
       <b>                                                                   
          &nbsp&nbsp&nbsp&nbsp错误信息提示                                   
       </b>                                                                  
     </font>                                                                 
</p>                                                                         
                                                                             
<!--显示具体的错误-->                                                        
<p align=center>                                                             
      <font color=green size=5 align=center>                                 
         <b>                                                                 
            &nbsp&nbsp<?echo"$error"?>                                       
         </b>                                                                
      </font>                                                                
</p>                                                                         
                                                                             
<!--显示返回的按钮-->                                                        
<div align=center>                                                           
      <a href="javascript:history.back()"><image src="http://www.pushad.com/info/images/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>                   
  欢迎光临金风社区&nbsp&nbsp&nbsp&nbsp&nbsp                                
  这是我们的php乐园&nbsp&nbsp&nbsp&nbsp&nbsp                               
  希望您能喜欢它~&nbsp&nbsp&nbsp&nbsp&nbsp                                
</marquee>                                                                 
<!--显示一面迎风飘扬的旗帜作为欢迎信息-->                                  
<img src="http://www.pushad.com/info/images/flag.gif" align=left>                                     
<!--显示本页面的大标题-->                                                  
<h2 align=center color=red>                                                
   金风社区欢迎您!                                                        
</h2>                                                                      
<!--显示一条红色的水平的分隔线-->                                          
<hr color=red>                                                             
<!--显示欢迎信息-->                                                        
<p align=center>                                                           
  <font color=red size=5 align=center>                                     
   <b>                                                                     
     &nbsp&nbsp&nbsp&nbsp您已经成功了!恭喜恭喜                            
   </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>                                                                  
        &nbsp&nbsp请选择继续或者退回                                       
      </b>                                                                 
   </font>                                                                 
</p>                                                                       
<!--对最下面的按钮进行说明-->                                              
<p align=center>                                                           
    <font color=green size=4>                                              
      <b>                                                                  
        &nbsp&nbsp选择左边的按钮继续登记                                   
      </b>                                                                 
    </font>                                                                
    <font color=green size=4>                                              
      <b>                                                                  
        &nbsp&nbsp选择右边的按钮退回到主界面                               
      </b>                                                                 
    </font>                                                                
</p>                                                                       
<!--显示两个动态的按钮-->                                                  
<div align=center>                                                         
      <a href="login.php"><image src="http://www.pushad.com/info/images/continue.gif" align=center></a>
      <a href="mainform.php"><image src="http://www.pushad.com/info/images/back.gif"align=center></a> 
</div>                                                                     
</body>                                                                    
</html>                                                                                                                   




收集最实用的网页特效代码!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表