PHP的bbs实现之二

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介:
1. on_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 $ok_info ?>                                                
   </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="bookin.php">                                            
        <image src="images/continue.gif" align=center border=0></a>    
      <a href="mainform.php">                                          
        <image src="images/quit.gif" align=center border=0></a>        
</div>                                                                 
</BODY>                                                                
</HTML>                                                                 
2. login.php
<? 
 include "common.inc.php";    
function User_Password($log_id)
{
  global $USER_LOG_TABLE;
  $SQL="SELECT password FROM $USER_LOG_TABLE WHERE log_id='$log_id'";
  $result=mysql_query($SQL) or die(mysql_error());
  $row=mysql_fetch_Array($result);
  return($row[password]);
}
function AddOneUser()
{
  global $USER_LOG_TABLE,$USER_ONLINE_TABLE,$REMOTE_ADDR;
  global $log_id,$nicker,$log_count,$log_time;
  global $arc_count,$gender,$level,$right,$exp_count,$log_ip;
  
  $log_time=time();         
  $log_ip=$REMOTE_ADDR;
                        
  $SQL="DELETE FROM $USER_ONLINE_TABLE WHERE log_id='$log_id'";
  mysql_query($SQL) or die(mysql_error());
  $SQL="SELECT * FROM $USER_LOG_TABLE WHERE log_id='$log_id'";
  $result=mysql_query($SQL) or die(mysql_error());
  $row=mysql_fetch_Array($result);
  
  $nicker=$row[nicker];
  $log_count=$row[log_count];
  $arc_count=$row[arc_count];
  $gender=$row[gender];
  $level=$row[level];
  $right=$row[right];
  $exp_count=$row[exp_count];
  
  $SQL="INSERT INTO $USER_ONLINE_TABLE (
          log_id,nicker,log_count,log_time,arc_count,
          gender,level,right,exp_count,log_ip
        ) VALUES (
          '$log_id','$nicker','$log_count','$log_time',
          '$arc_count','$gender','$level','$right','$exp_count','$log_ip'
        )";
  mysql_query($SQL) or die(mysql_error());
}

function CheckNicker($nicker_input) 
{
  global $USER_LOG_TABLE;
  global $nicker,$log_id;
  $SQL="SELECT * FROM $USER_LOG_TABLE WHERE nicker='$nicker_input'";
  $result=mysql_query($SQL) or die(mysql_error());
  $row=mysql_fetch_Array($result);               
  $log_id=$row[log_id];
  $nicker=$row[nicker];
  
  if (!$row[nicker]) return "error!";
}        
if ($Ok) {       
  if (!$username) $error="用户名不能为空"; 
  if(CheckNicker($username)) $error="用户名不存在";
  if (!$password) $error="请输入你的密码";
    if (!isset($error)) 
    {
      $p=User_Password($log_id);
      if ($password!=$p) $error="密码不正确";
    }
                                          
   if (!isset($error)) 
   {
           AddOneUser();
           header("Location: on_ok.php?log_id=$log_id\n");
   }
   else
       header("Location: login_error.php?error=$error\n");    
  }
 include "header.inc.php";
?>
<BODY>
<FORM METHOD="POST" ACTION="<? echo $PHP_SELF; ?>">
  <TABLE width=60% border=0 align=center bgcolor=yellow>
    <TR  bgcolor=green>
      <TD height=20 align=center>
           <FONT  class=myYellow>
             请认真输入您的昵称和密码!
          </FONT>
      </TD>
    </TR>               
    
    <TR >
      <TD height=50 align=center>用户名:
        <INPUT type=text name=username size=20 maxlength=20>
      </TD>
    </TR>
    
    <TR>
      <TD height=30 width=18% align=center>密 码:
        <INPUT type=password name=password size=20 maxlength=10>
      </TD>
    </TR>
    
    <TR>
      <TD height=20 align=center>
        <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>
3.bookin.php
<?                                                                                               
include "common.inc.php";                                                                        
                                                                                                 
function ReadUserAttr() {                                                                        
  global $USER_ATTR_TABLE,$USER_LOG_TABLE;                                                       
  global $log_id,$nicker,$realname,$email,$address,$birthday,                                    
         $oicq,$last_time,$homepage,$merriage,$edu_level,                                        
         $edu_school,$province,$city,$postalcode,$fond;                                          
  $SQL="SELECT nicker FROM $USER_LOG_TABLE WHERE log_id=$log_id";                                
                                                                                                 
  $result=mysql_query($SQL) or die(mysql_error());                                               
  $row=mysql_fetch_Array($result);                                                               
                                                                                                 
  $nicker=$row[nicker];                                                                          
                                                                                                 
  $SQL="SELECT * FROM $USER_ATTR_TABLE WHERE log_id=$log_id";                                    
  $result=mysql_query($SQL) or die(mysql_error());                                               
                                                                                                 
  $row=mysql_fetch_Array($result);                                                               
                                                                                                 
  $birthday=$row[birthday];                                                                      
  $realname=$row[realname];                                                                      
  $email=$row[email];                                                                            
  $address=$row[address];                                                                        
  $oicq=$row[oicq];                                                                              
  $last_time=$row[last_time];                                                                    
  $homepage=$row[homepage];                                                                      
  $merriage=$row[merriage];                                                                      
  $edu_level=$row[edu_level];                                                                    
  $edu_school=$row[edu_school];                                                                  
  $province=$row[province];                                                                      
  $city=$row[city];                                                                              
  $postalcode=$row[postalcode];                                                                  
  $fond=$row[fond];                                                                              
}                                                                                                
                                                                                                 
function UpdateUserNickname() {                                                                  
  global $USER_LOG_TABLE,$USER_ONLINE_TABLE;                                                     
  global $log_id,$nicker;                                                                        
  $SQL="UPDATE $USER_LOG_TABLE SET nicker='$nicker'                                              
       WHERE log_id='$log_id'";                                                                  
  mysql_query($SQL) or die(mysql_error());                                                       
                                                                                                 
}                                                                                                
                                                                                                 
function UpdateUserAttr() {                                                                      
  global $USER_ATTR_TABLE;                                                                       
  global $log_id,$realname,$email,$address,$birthday,$oicq,                                      
         $last_time,$homepage,$merriage,$edu_level,$edu_school,                                  
         $province,$city,$postalcode,$fond;                                                      
  $SQL="UPDATE $USER_ATTR_TABLE SET                                                              
          realname='$realname',email='$email',address='$address',                                
          birthday='$birthday', oicq='$oicq',homepage='$homepage',                               
          edu_level='$edu_level', edu_school='$edu_school',                                      
          merriage='$merriage',province='$province',city='$city',                                
          postalcode='$postalcode',fond='$fond'                                                  
        WHERE log_id='$log_id'";                                                                 
                                                                                                 
  mysql_query($SQL) or die(mysql_error());                                                       
}                                                                                                
                                                                                                 
if ($Ok)                                                                                         
{                                                                                                
  $birthday=$year.":".$mon.":".$day;                                                             
  $fond='1';                                                                                     
  if($radiobutton==1)                                                                            
     {$merriage='Y';}                                                                            
  else                                                                                           
     {$merriage='N';}                                                                            
  if($sport)$fond=$fond."S";                                                                     
  if($literature)$fond=$fond."L";                                                                
  if($music)$fond=$fond."M";                                                                     
  if($computer)$fond=$fond."C";                                                                  
  UpdateUserNickname();                                                                          
  UpdateUserAttr();                                                                              
  header("Location: on_ok.php?ok_info=用户的资料更新成功");                                      
  exit;                                                                                          
}                                                                                                
else                                                                                             
{                                                                                                
  ReadUserAttr();                                                                                
  if($merriage=='Y')                                                                             
     {$radiobutton=1;}                                                                           
  else                                                                                           
     {$radiobutton=0;}                                                                           
  $temp_date=split(":",$birthday);                                                               
  $year=$temp_date[0];                                                                           
  $mon=$temp_date[1];                                                                            
  $day=$temp_date[2];                                                                            
  if (strrpos($fond,'S')){$sport=1;}else $sport=0;                                               
  if (strrpos($fond,'L')){$literature=1;}else $literature=0;                                     
  if (strrpos($fond,'M')){$music=1;}else $music=0;                                               
  if (strrpos($fond,'C')){$computer=1;}else $computer=0;                                         
}                                                                                                
include "header.inc.php";                                                                        
?>                                                                                               
<html>                                                                                           
<body bgcolor="#FFFFFF">                                                                         
<TABLE width=100% border=0 align=left>                                                           
  <TR>                                                                                           
    <TD height=25 align=center>                                                                  
        <FONT class=myRed>                                                                       
         <?echo "用 户 情  况 表"?>                                                           
        </FONT>                                                                                  
    </TD>                                                                                        
  </TR>                                                                                          
</TABLE>                                                                                         
                                                                                                 
<hr>                                                                                             
                                                                                                 
<FORM METHOD="POST" ACTION=                                                                      
      "<? echo $PHP_SELF."?log_id=".$log_id; ?>">                                                
  <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>                                                                                         
      <TD height=20 width=50% align=left class=myRed>                                            
            昵&nbsp&nbsp&nbsp&nbsp称&nbsp                                                        
        <INPUT type=text name=nicker maxlength=20                                                
             value="<? echo $nicker; ?>" >                                                       
      </TD>                                                                                      
      <td width="50%" align=left class=myRed>                                                    
           婚&nbsp&nbsp&nbsp&nbsp否&nbsp                                                         
        <input type="radio" name="radiobutton" value=1                                           
             <? if ($radiobutton==1) {echo "checked";}?>>                                        
        已婚                                                                                     
        <input type="radio" name="radiobutton" value=0                                           
             <? if ($radiobutton==0) {echo "checked";}?>>                                        
        未婚 </td>                                                                               
    </TR>                                                                                        
    <TR>                                                                                         
      <TD height=20 width=50% align=left class=myRed>真实姓名&nbsp                               
        <INPUT type=text name=realname maxlength=20                                              
              value="<? echo $realname; ?>" >                                                    
      </TD>                                                                                      
    <TD width=32% width=50% align=left class=myRed>                                              
           生&nbsp&nbsp&nbsp&nbsp日&nbsp                                                         
      <SELECT name="year" size="1" class=myRed>                                                  
    <?                                                                                           
       for ($i=1950;$i<=2000;$i++) {                                                             
            echo "        <OPTION value=\"$i\"";                                                 
            echo ($year=="$i") ? " selected" : "";                                               
            echo ">$i</OPTION>\n";                                                               
            }                                                                                    
    ?>                                                                                           
      </SELECT>                                                                                  
        年                                                                                       
<SELECT name="mon" size="1" class=myRed>                                                         
<?                                                                                               
  for ($i=1;$i<=12;$i++) {                                                                       
    echo "        <OPTION value=\"";                                                             
    echo ($i<10) ? "0$i" : "$i";                                                                 
    echo "\"";                                                                                   
    echo ($mon=="$i") ? " selected" : "";                                                        
    echo ">";                                                                                    
    echo ($i<10) ? "0$i" : "$i";                                                                 
    echo "</OPTION>\n";                                                                          
  }                                                                                              
?>                                                                                               
</SELECT>                                                                                        
        月                                                                                       
<SELECT name="day" size="1" class=myRed>                                                         
<?                                                                                               
  for ($i=1;$i<=31;$i++) {                                                                       
    echo "        <OPTION value=\"";                                                             
    echo ($i<10) ? "0$i" : "$i";                                                                 
    echo "\"";                                                                                   
    echo ($day=="$i") ? " selected" : "";                                                        
    echo ">";                                                                                    
    echo ($i<10) ? "0$i" : "$i";                                                                 
    echo "</OPTION>\n";                                                                          
  }                                                                                              
?>                                                                                               
      </SELECT></td>                                                                             
    </TR>                                                                                        
    <tr>                                                                                         
    <TD width=50% align=left class=myRed>                                                        
          学&nbsp&nbsp&nbsp&nbsp历&nbsp                                                          
      <SELECT name="edu_level" class=myBlack>                                                    
        <OPTION value="1"<? echo ($edu_level==1)                                                 
               ? " selected" : ""; ?>>小学</OPTION>                                              
        <OPTION value="2"<? echo ($edu_level==2)                                                 
               ? " selected" : ""; ?>>初中</OPTION>                                              
        <OPTION value="3"<? echo ($edu_level==3)                                                 
               ? " selected" : ""; ?>>高中</OPTION>                                              
        <OPTION value="4"<? echo ($edu_level==4)                                                 
               ? " selected" : ""; ?>>中专</OPTION>                                              
        <OPTION value="5"<? echo ($edu_level==5)                                                 
               ? " selected" : ""; ?>>大专</OPTION>                                              
        <OPTION value="6"<? echo ($edu_level==6)                                                 
               ? " selected" : ""; ?>>大学</OPTION>                                              
        <OPTION value="7"<? echo ($edu_level==7)                                                 
               ? " selected" : ""; ?>>硕士</OPTION>                                              
        <OPTION value="8"<? echo ($edu_level==8)                                                 
               ? " selected" : ""; ?>>博士</OPTION>                                              
      </SELECT>                                                                                  
    </TD>                                                                                        
      <td width="50%" align="left" class=myRed>毕业院校&nbsp                                     
        <input type="text" name="edu_school" size="20"                                           
             maxlength="20" value=<?echo $edu_school;?>>                                         
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td width="50%" align="left" class=myRed>                                                  
            省&nbsp&nbsp&nbsp&nbsp份&nbsp                                                        
        <input type="text" name="province" value=<?echo $province;?>>                            
      </td>                                                                                      
      <td width="50%" align="left" class=myRed>                                                  
             城&nbsp&nbsp&nbsp&nbsp市&nbsp                                                       
        <input type="text" name="city" maxlength="12"                                            
             size="12" value=<?echo $city;?>>                                                    
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td width="50%" align="left" class=myRed>                                                  
             邮&nbsp&nbsp&nbsp&nbsp编&nbsp                                                       
        <input type="text" name="postalcode" value=<?echo $postalcode;?>>                        
      </td>                                                                                      
      <td width="50%" align="left" class=myRed>OICQ&nbsp&nbsp号&nbsp                             
        <input type="text" name="oicq" size="8"                                                  
               maxlength="8" value=<?echo $oicq;?>>                                              
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td colspan="2" align="left" class=myRed>通信地址&nbsp                                     
          <input type="text" name="address"                                                      
             size="40" value=<?echo $address;?>>                                                 
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td colspan="2">                                                                           
        <div align=left align="left" class=myRed>电子邮件信箱                                    
          <input type="text" name="email" size="50"                                              
               maxlength="50" value=<?if (strlen($email)<5)                                      
                    echo"@";else echo $email;?>>                                                 
        </div>                                                                                   
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td colspan="2">                                                                           
        <div align="left" align="left" class=myRed>主页地址&nbsp                                 
          <input type="text" name="homepage" size="50"                                           
              value=<?if (strlen($homepage)<9)                                                   
                     { echo "http://";} else  echo $homepage;?>>                                 
        </div>                                                                                   
      </td>                                                                                      
    </tr>                                                                                        
    <tr>                                                                                         
      <td colspan="2">                                                                           
        <div align="left" align="left" class=myRed>                                              
                爱&nbsp&nbsp&nbsp&nbsp好&nbsp                                                
          <input type="checkbox" name="sport"                                                    
                <?if ($sport==1)echo "checked";?>>                                               
          体育                                                                                   
          <input type="checkbox" name="literature"                                               
                <?if ($literature==1)echo "checked";?>>                                          
          文学                                                                                   
          <input type="checkbox" name="music"                                                    
                <?if ($music==1)echo "checked";?>>                                               
          音乐                                                                                   
          <input type="checkbox" name="computer"                                                 
                <?if ($computer==1)echo "checked";?>>                                            
          计算机 </div>                                                                          
      </td>                                                                                      
    </tr>                                                                                        
    <TR class=myBlack>                                                                           
      <TD height=30 width=80% colspan=2 align=center><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>  









本文转自 牛海彬 51CTO博客,原文链接:http://blog.51cto.com/newhappy/76895,如需转载请自行联系原作者
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
存储 算法 PHP
唯一ID生成原理与PHP实现-雪花算法
唯一ID生成原理与PHP实现-雪花算法
657 0
唯一ID生成原理与PHP实现-雪花算法
|
缓存 移动开发 NoSQL
php结合redis实现高并发下的抢购、秒杀功能的实例
php结合redis实现高并发下的抢购、秒杀功能的实例
257 0
|
PHP
github与gitee代码自动同步到服务器实现PHP项目自动部署webhooks
github与gitee代码自动同步到服务器实现PHP项目自动部署webhooks
517 0
github与gitee代码自动同步到服务器实现PHP项目自动部署webhooks
|
网络协议 Linux 网络安全
php实现websocket实时消息推送
php实现websocket实时消息推送
533 0
php实现websocket实时消息推送
|
PHP
php实现数字格式化,数字每三位加逗号的功能函数169856420=&gt;169,856,420
php实现数字格式化,数字每三位加逗号的功能函数169856420=&gt;169,856,420
216 0
|
PHP
PHP实现Workerman实例 高性能PHP Socket即时通讯框架
PHP实现Workerman实例 高性能PHP Socket即时通讯框架
426 0
|
消息中间件 PHP Windows
PHP实现php-amqplib/php-amqplib实例RabbitMq
PHP实现php-amqplib/php-amqplib实例RabbitMq
261 0
|
XML 移动开发 JSON
PHP使用yansongda/pay实现支付宝和微信的支付
PHP使用yansongda/pay实现支付宝和微信的支付
1083 0
|
NoSQL PHP Redis
PHP结合redis实现点赞功能
PHP结合redis实现点赞功能
144 0
|
消息中间件 缓存 JSON
PHP实现think-queue介绍
PHP实现think-queue介绍
431 0