开发者社区> 余二五> 正文
阿里云
为了无法计算的价值
打开APP
阿里云APP内打开

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>             
          &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 [url]www.fecit.com[/url], ";          
  $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="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="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="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="images/continue.gif" align=center></a>
      <a href="mainform.php"><image src="images/back.gif"align=center></a>  
</div>                                                                      
</BODY>                                                                     
</HTML>  








本文转自 牛海彬 51CTO博客,原文链接:http://blog.51cto.com/newhappy/76898,如需转载请自行联系原作者

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
php实现数字格式化,数字每三位加逗号的功能函数169856420=>169,856,420
php实现数字格式化,数字每三位加逗号的功能函数169856420=>169,856,420
0 0
PHP实现Workerman实例 高性能PHP Socket即时通讯框架
PHP实现Workerman实例 高性能PHP Socket即时通讯框架
0 0
PHP实现php-amqplib/php-amqplib实例RabbitMq
PHP实现php-amqplib/php-amqplib实例RabbitMq
0 0
PHP使用yansongda/pay实现支付宝和微信的支付
PHP使用yansongda/pay实现支付宝和微信的支付
0 0
PHP结合redis实现点赞功能
PHP结合redis实现点赞功能
0 0
PHP实现think-queue介绍
PHP实现think-queue介绍
0 0
php实现定时任务hellogerard/jobby
php实现定时任务hellogerard/jobby
0 0
PHP实现JWT lcobucci/jwt生成jwt token
PHP实现JWT lcobucci/jwt生成jwt token
0 0
PHP实现定时任务hellogerard/jobby实例
PHP实现定时任务hellogerard/jobby实例
0 0
PHP实现极光推送jpush/jpush 手机APP消息推送
PHP实现极光推送jpush/jpush 手机APP消息推送
0 0
+关注
文章
问答
文章排行榜
最热
最新
相关电子书
更多
PHP安全开发_从白帽角度做安全
立即下载
PHP在机器学习上的应用及云深度学习平台的架构设计与实现
立即下载
PHP与APM_技术内幕和最佳实践
立即下载