程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> PHP+DBM的同學錄程序(4)

PHP+DBM的同學錄程序(4)

編輯:PHP綜合
8、注冊文件reg.php3
<?
require("common.php3");
require("mail.php3");
if($submit){
  if($id=="")error("請填寫您的注冊用戶名!");
  elseif(!eregi("^[0-9a-zA_Z]+$",$id))error("你的用戶名不能含有其他字符!");
  elseif($password=="")error("請填寫您的密碼!");
  elseif($password<>$password1)error("您的密碼填寫不正確!");
  elseif($name=="")error("請填寫您的名字!");
  elseif($mail=="")error("請填寫您的郵件地址!");
  else{
    $dbm=dbmopen("class","w");
    if(dbmexists($dbm,$id))error("這個用戶名已經給別人注冊了!");
    else{
      $intro=nl2br($intro);
      $data="$name|!:!|$nickname|!:!|$mail|!:!|$home|!:!|$oicq|!:!|$icq|!:!|$add|!:!|$tel|!:!|$birth|!:!|$job|!:!|$intro|!:!|$sex";
      dbminsert($dbm,$id,$data);
      $pwd=dbmopen("password","w");
      dbminsert($pwd,$id,$password);
    }
    dbmclose($dbm);
    $sendmsg="歡迎注冊《深圳中學2000屆高中(12)班同學錄》n";
    $sendmsg.="下面是您的注冊信息:n";
    $sendmsg.="用戶名:$idn用戶密碼;$passwordn";
    $sendmsg.="=====================================================";
    $sendmsg.="注冊姓名:$namen注冊昵稱:$nicknamen注冊郵箱:$mailn主頁地址:$homen";
    $sendmsg.="您的OICQ:$oicqn您的 ICQ:$icqn聯系地址:$addn聯系電話:$teln";
    $sendmsg.="您的生日:$birthn您的職業:$jobn您的性別;$sexn您的個人介紹:n$intronn";
    $sendmsg.="======================================================";
    $sendmsg.="歡迎注冊《深圳中學2000屆高中(12)班同學錄》";
    $sendmsg.="登陸地址:http://5212.net/class/";
    mail2("歡迎注冊《深圳中學2000屆高中(12)班同學錄》",$sendmsg,$mail);
    header("Location:index.php3");
  }
}else{
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>同學錄用戶注冊</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<link rel="stylesheet" href="style.css">
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
</HEAD><BODY bgcolor="#FFFFFF" topMargin=0>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%"><BR>
<DIV align=center></DIV><CENTER><TBODY></TBODY></center>
  </TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="60%" align="center">
<TBODY> <TR vAlign=top>
    <TD bgColor=#000000 width="100%" height="336">  
      <DIV align=center>
        <TABLE border=0 cellPadding=4 cellSpacing=1 height=390 width=586>
          <TBODY>  
          <TR>  
            <TD align=middle bgColor=#2f5e8c colSpan=2 height=14 vAlign=top><form method="POST" action="reg.php3"> <FONT color=#ffffff>注冊同學錄</FONT></TD>
          </TR>
          <TR>  
            <TD align=middle bgColor=#ffffff height=25 width=150>注冊用戶名: </TD>
            <TD align=left bgColor=#ffffff height=25 width=400>  
              <INPUT class=stedit maxLength=10 name=id size=23>
              *必須填寫</TD>
          </TR>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的密碼: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=10 name=password size=23 type="password">
              *必須填寫 </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>重復密碼: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input type="password" class="stedit" name="password1" size="23" value="">
              *必須填寫 </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>NickName: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=20 name=nickname size=23>
            </td>
          </tr>
          <TR>  
            <TD align=middle bgColor=#ffffff height=25 width=121>電子郵件: </TD>
            <TD align=left bgColor=#ffffff height=25 width=486>  
              <INPUT class=stedit maxLength=30 name=mail size=23>
              *必須填寫 </TD>
          </TR>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的OICQ: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=9 name=oicq size=23>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的主頁: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=50 name=home size=23 value="http://">
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的 ICQ: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=10 name=icq size=23>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的名字: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=10 name=name size=23>
              *必須填寫 </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的電話: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=20 name=tel size=23>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>出生日期: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=11 name=birth size=23>
              *類似2000-10-10 </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>聯系地址: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <input class=stedit maxlength=50 name=add size=23>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的職業: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <select name="job">
                <option value="學 生">學 生</option>
                <option value="老 師">老 師</option>
                <option value="其 他">其 他</option>
              </select>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>您的性別: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <select name="sex">
                <option value="俊  男">俊  男</option>
                <option value="靓  女">靓  女</option>
                <option value="其  他">其  他</option>
              </select>
            </td>
          </tr>
          <tr>  
            <td align=middle bgcolor=#ffffff height=25 width=121>個人簡介: </td>
            <td align=left bgcolor=#ffffff height=25 width=486>  
              <textarea class="stedit" name="intro" cols="40" rows="4"></textarea>
            </td>
          </tr>
          <TR bgColor=#ffedc8>  
            <TD bgColor=#ffffff colSpan=2>  
              <div align="center">  
                <input type="submit" name="submit" value="確認申請" class="stbtm">
                  
                <input type="reset" name="reset" value="注冊重置" class="stbtm">
              </div></form>
            </TD>
          </TR>
          </TBODY>  
        </TABLE>
      </DIV></TR></TBODY></TABLE><BR><TR><TD></TD></TR>
</BODY>
</HTML>
<?
}
?>

9、建立數據庫的文件run.php3
<?

$dbm=dbmopen("class","c");
dbmclose($dbm);
$dbm=dbmopen("password","c");
dbmclose($dbm);
?> 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved