会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > Web开发 > PHP
简单用户注册程序
发表日期:2004-07-21 15:57:33作者: 出处:  

第一步:首先做一个如下页面。
<html>
<head>
<title>申请帐号</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.p11 {  font-size: 10pt; color: #000000; text-decoration: none}
.c3a {font-size: 9pt; color: #000000; background-color: #ffffff; border: 1 solid #ff9900}
-->
</style>
</head>

<body bgcolor="#FFFFFF" topmargin="0">
<table width="440" border="0" cellspacing="0" cellpadding="0" align="center">
  <form method="post" action="zc.php">
    <tr>  
      <td width="230"><img src="/images/login.gif" width="200" height="30"></td>
      <td width="210" class="p11" valign="bottom"><font color="#FF6699">*</font>为必填项</td>
    </tr>
   
</table>
  <table width="440" border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#eeeeee" bordercolordark="#eeeeee" bordercolorlight="#ffcf60">
    <tr>  
      <td colspan="2">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="56%">  
              <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="170">
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">用户名:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="text" name="name" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font></span> </td>
                </tr>
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">密码:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="password" name="word" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font></span> </td>
                </tr>
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">确认密码:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="password" name="pass" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font> </span></td>
                </tr>
                <tr>  
                  <td width="111" height="29" class="p11">  
                    <div align="right">提示问题:</div>
                  </td>
                  <td width="207" height="29" class="p11">  
                    <input type="text" name="ask" size="20" class="c3a">
                  </td>
                </tr>
                <tr>  
                  <td width="111" height="28" class="p11">  
                    <div align="right">答案提示:</div>
                  </td>
                  <td width="207" height="28" class="p11">  
                    <input type="text" name="answer" size="20" class="c3a">
                  </td>
                </tr>
                <tr>  
                  <td colspan="2">  
                    <div align="center">  
                      <input type="submit" name="Submit" value="下一步" style="font-size: 10pt;color: #EFFB00; background-color: rgb(225,153,0)">
                      <input type="reset" name="Submit2" value="重来" style="font-size: 10pt;color: #EFFB00; background-color: rgb(225,153,0)">
                    </div>
                  </td>
                </tr>
              </table>
            </td>
            <td width="44%">
              <div align="center"><img src="/images/login1.gif" width="120" height="90"></div>
            </td>
          </tr>
        </table>
      </td>
    </tr></form>
  </table>

</body>
</html>

第二步:注册执行程序。
<?
mysql_connect("localhost","username","password")         /*请修改用户名和密码*/
or die("无法连接数据库,请重来");

mysql_select_db("数据库名")
or die("无法选择数据库,请重来");
$query="select id from 数据库表名 where username='$name'";   
/*从数据库中寻找相同名字的用户*/
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows !=0)  

/*如果找到了相同的用户的话,出现如下提示。*/
{
$temp='已有人注册此名,请重新选择名字!';

}

else
{
if ($word != $pass)
{
$temp = "密码输入不一致!";
}
else
{
if (!eregi("^[a-z][a-z0-9_.]{3,19}$",$name))
{
$temp = "用户名非法.";
}
else
{
$query="insert into MemberAuth values('0','$name','$word','1','$ask','$answer')"; /*找不到相同的就输入新的用户资料*/
mysql_query($query);
$temp = "<img src=imagessuee.gif><br><a href='javascript:window.close()'>关闭窗口</a>";
}
}
}
?>
<html>
<head>
<title>申请帐号</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.p11 {  font-size: 10pt; color: #000000; text-decoration: none}
.c3a {font-size: 9pt; color: #000000; background-color: #ffffff; border: 1 solid #ff9900}
-->
</style>
</head>

<body bgcolor="#FFFFFF" topmargin="0">
<table width="440" border="0" cellspacing="0" cellpadding="0" align="center">
  <form method="post" action="zc.php">
      <tr>  
      <td width="230"><img src="/images/login.gif" width="200" height="30"></td>
      <td width="210" class="p11" valign="bottom"><font color="#FF6699">*</font>为必填项</td>
    </tr>
   
</table>
  <table width="440" border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#eeeeee" bordercolordark="#eeeeee" bordercolorlight="#ffcf60">
    <tr>  
      <td colspan="2">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="56%">  
              <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="170">
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">用户名:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="text" name="name" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font></span> </td>
                </tr>
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">密码:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="password" name="word" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font></span> </td>
                </tr>
                <tr>  
                  <td width="111" class="p11">  
                    <div align="right">确认密码:</div>
                  </td>
                  <td width="207" class="p11">  
                    <input type="password" name="pass" size="20" class="c3a">
                  <span class="p11"><font color="#FF6699">*</font> </span></td>
                </tr>
                <tr>  
                  <td width="111" height="29" class="p11">  
                    <div align="right">提示问题:</div>
                  </td>
                  <td width="207" height="29" class="p11">  
                    <input type="text" name="ask" size="20" class="c3a">
                  </td>
                </tr>
                <tr>  
                  <td width="111" height="28" class="p11">  
                    <div align="right">答案提示:</div>
                  </td>
                  <td width="207" height="28" class="p11">  
                    <input type="text" name="answer" size="20" class="c3a">
                  </td>
                </tr>
                <tr>  
                  <td colspan="2">  
                    <div align="center">  
                      <input type="submit" name="Submit" value="下一步" style="font-size: 10pt;color: #EFFB00; background-color: rgb(225,153,0)">
                      <input type="reset" name="Submit2" value="重来" style="font-size: 10pt;color: #EFFB00; background-color: rgb(225,153,0)">
                    </div>
                  </td>
                </tr>
              </table>
            </td>
            <td width="44%" class=p11 align=center>
             
            <? echo $temp; ?>
                           
            </td>
          </tr>
        </table>
      </td>
    </tr></form>
  </table>

</body>
</html>

本人是初学php与mysql,望请各位同盟多加支持。如想执行此程序请到htpp://lyjrich.oso.com.cn注册便知。或者与我写信lyjrich@sina.com.


【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】   

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.0015