程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 用戶的詳細注冊和判斷

用戶的詳細注冊和判斷

編輯:關於PHP編程

有三個文件:
第一是:zcyh.php(注冊用戶名)<?include("header1.inc.php")?>
<div align=center>
<table width="89%" border="0">
    <tr>  
      <td><font color="#ff0000">當前位置:<a href="index.php">主頁</a>>>注冊頁面</font></td>
    </tr>
  </table><br>

  <table width="82%" border="0" height="27">
    <tr>  
      <td height="14"><b><font color="#660099"><img src="images/dyb.gif" width="68" height="22">  
        請設定用戶名:(<font color="#FF0000">3-15位</font>)</font></b></td>
    </tr>
  </table>
  <form name="form1" method="post" action="register.php">
    <table width="80%" border="0" height="154">
      <tr>  
        <td width="42%">  
          <div align="right"><font color="#0000FF">用戶名:</font>
        </td>
        <td width="58%">  
          <input type="text" name="name" maxlength="20">
        </td></div>
      </tr>
      <tr>  
        <td colspan="2" height="27">  
          <div align="left"><font size="2"><font color="#FF0000">注意:</font><font color="#0000FF">用戶名只能由英文字母(a-z),數字(0-9)和下劃線('_'、'-'、'.'  
            )構成,不能有空格,且必須以英文字母為開頭。 </font></font> </div>
        </td>
      </tr>
      <tr>  
        <td colspan="2" height="14">  
          <div align="left"><font size="2"><font color="#FF0000">例如:</font></font></div>
        </td>
      </tr>
      <tr>  
        <td colspan="2">  
          <div align="center"><font size="2" color="#FF0000"><b><font color="#0000FF">√</font></b>正確的例子:jocky、lin_xing、nh2001</font></div>
        </td>
      </tr>
      <tr>  
        <td colspan="2">  
          <div align="center"><font size="2" color="#FF0000"><b><font color="#0000FF">×</font></b>錯誤的例子:li  
            kitty、ming:)、168kk</font></div>
        </td>
      </tr>
      <tr>  
        <td colspan="2" height="18">  
          <div align="center"><font size="2" color="#0000FF">如果你已經填寫好,請點“</font><font size="2"><font color="#FF0000">下一步</font><font color="#0000FF">”按鈕;  
            點“</font><font color="#FF0000">取消</font><font color="#0000FF">”按鈕即取消您剛才的輸入,重新開始。</font>  
            </font></div>
        </td>
      </tr>
      <tr>  
        <td colspan="2" height="19">  
          <div align="center">  

            <input type=image name=name2 src="images/xyb.gif" width="68" height="22" border="0">
           <input type=hidden name=name3 value=<?echo$name?>>
             <a href="zcyh.php"><img src="images/cancel.gif" width="68" height="22" border="0"></a></div>
        </td>
      </tr>
    </table>
  </form>
<br>

</div>
<br>
<?include("foot.inc.php")?>
</body>
</html>
第二個是:register.php(判斷注冊用戶名是否正確和是否重復,然後輸出注冊的詳細表單)
<?include("header1.inc.php")?>
<div align=center>
<table width="89%" border="0">
    <tr>  
      <td><font color="#ff0000">當前位置:<a href="index.php">主頁</a>>><a href=zcyh.php>注冊頁面</a>>>詳細資料</font></td>
    </tr>
  </table><br>
<?
if($name==""){
    echo"<br><center><font color=blue>用戶名不能為空。請</font><a href=zcyh.php>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if(strlen($name)<3 || strlen($name)>15){
    echo"<br><center><font color=blue>用戶名的長度不符合要求。請</font><a href=zcyh.php>返回</a></center><br>";
  include("foot.inc.php");
    exit();
}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*$", $name)) {
       echo"<br><center><font color=blue>注冊名只能由字母數字組成.請</font><a href=zcyh.php>返回</a></center><br>";
      include("foot.inc.php");
    exit();
    }
if ($name)
    {     
        $conn=@mysql_connect("localhost");
        $sql=@mysql_select_db("jocky",$conn);
        $result=@mysql_query("select * from user1 where name='$name'" ,$conn);
        if($result){
             if(@mysql_fetch_object($result)){
                 echo"<br><center><font color=blue>對不起,已經有相同的用戶名!請</font><a href=zcyh.php>返回</a>.</center><br>";}
                 else{$conn=@mysql_connect("localhost");
                      $sql=@mysql_select_db("jocky",$conn);
                      $sqldo="insert into user1 (name) values ('$name')";
                     @mysql_query($sqldo,$conn);
                 echo"<br><center><font color=blue>你好,</font>";
                 echo"<font color=red><b>$name</b></font></center>";
                 include("zhuce.php");
                 @mysql_close($conn);}
                include("foot.inc.php");
                 exit();
             }
        }
    ?>
    </div>
<?include("foot.inc.php")?>
</body>
</html>
第三個是:check.php(判斷注冊資料是否正確,然後插入數據庫,重新登錄)
<?include("header1.inc.php")?>
<div align=center>  
<table width="89%" border="0">
    <tr>  
      <td><font color="#ff0000">當前位置:<a href="index.php">主頁</a>>><a href=zcyh.php>注冊頁面</a>>>詳細資料</font></td>
    </tr>
  </table><br>
<?
if($truename==""){
    echo"<br><center><font color=blue>真實姓名不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if($password==""||$repassword==""){
    echo"<br><center><font color=blue>密碼不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if($repassword!=$password){
    echo"<br><center><font color=blue>兩次輸入的密碼不一樣。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if(strlen($password)<6 || strlen($password)>15){
    echo"<br><center><font color=blue>密碼的長度不符合要求。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
  include("foot.inc.php");
    exit();
}
if($pwwhat==""){
    echo"<br><center><font color=blue>密碼提示問題不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if($pwan==""){
    echo"<br><center><font color=blue>密碼提示答案不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if($personalid==""){
    echo"<br><center><font color=blue>身份證號碼不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if(strlen($personalid)!=15 or strlen($personalid)!=18){
    echo"<br><center><font color=blue>輸入的身份證號碼不是15位或18位。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
  include("foot.inc.php");
    exit();
}*/
if($year=="" || $month=="" || $day==""){
    echo"<br><center><font color=blue>出生年月日沒有填。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
  include("foot.inc.php");
    exit();
}
if(strlen($year)!=4 || strlen($month)!=2 || strlen($day)!=2){
    echo"<br><center><font color=blue>輸入的年月日不正確。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
  include("foot.inc.php");
    exit();
}
if (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$",$email)) {
echo"<br><center><font color=blue>E-Mail地址格式不對。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
    }
if($tel==""){
    echo"<br><center><font color=blue>聯系的電話不能為空。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if(strlen($tel)!=11 || strlen($tel)!=12 || strlen($tel)!=13){
    echo"<br><center><font color=blue>聯系的電話長度不正確。請</font><a href=javascript:history.go(-1);>返回</a></center><br>";
    include("foot.inc.php");
    exit();
}
if($gender==""){
    $null1="空";}
if($xueli==""){
    $null2="空";}
if($money==""){
    $null3="空";}
if($addr==""){
    $null4="空";}
      $birthday="$year.-.$month.-.$day";
      $time=time();
      $conn=@mysql_connect("localhost");
      $sql=@mysql_select_db("jocky",$conn);
      $result=@mysql_query("select * from user1 where name='$name'" ,$conn);
      $sqldo="insert into user1 (name,truename,password,pwwhat,pwan,personalid,gender,xueli,birth,email,tel,money,addr,time) values('$name','$truename','$password','$pwwhat','$pwan','$personalid','$null1','$null2',";
     $sqldo.="'$birthday','$email','$tel','$null3','$null4','$time')";
      $query=@mysql_query($sqldo,$conn);
      if($query){
      echo"<br><center><font color=blue>恭喜你,你已注冊成功!請</font><a href=index.php>登錄</a></center><br>";
        exit();
          }else{
              echo"<br><center><font color=blue>服務器忙,不能為你注冊,請稍後再注冊!</font><a href=index.php>回主頁</a></center><br>";
          }
        @mysql_close($conn);
?>
</div>
<?include("foot.inc.php")?>
</body>
</html>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved