php会员注册前台-找回密码,修改资料

忘记密码
wangjimima.php
<body>
<table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><span class="style7">找回密码第一步</span></td>
  </tr>
</table>
<form action="wangjimima1.php" method="post" name="form3" id="form3">
  <table width="40%"  border="0" align="center" cellpadding="5" cellspacing="0" class="biaoge">
    <tr>
      <td height="20" colspan="2" class="danyuange"><div align="center">请输入您的用户名</div></td>
    </tr>
    <tr>
      <td width="24%" height="20" class="left"><div align="center">用户名 </div></td>
      <td width="76%" class="danyuange"><div align="center">
        <input name="admin" type="text" class="wenben" id="admin" />
      </div></td>
    </tr>
    <tr>
      <td height="20" colspan="2"><div align="center"> &nbsp;
        &nbsp;&nbsp;&nbsp;
                                 <input type="submit" name="Submit2" value="下一步" />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="reset" name="Submit" value="取消" />
      </div></td>
    </tr>
  </table>
</form>
</body>

wangjimima1.php
<body>
<?php
 $sql = "select * from member where admin='$_POST[admin]'";
 $result =mysql_query($sql,$connec);
if ($rs =mysql_fetch_array($result)){

 ?>
<table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><span class="style17">找回密码第二步</span></td>
    </tr>
  </table>
  <form action="wangjimima2.php" method="post" name="form3" id="form3">
    <p>
      <?php
   $sql = "select * from member where admin='$_POST[admin]'";
   $result =mysql_query($sql,$connec);
  $rs =mysql_fetch_array($result);

 ?>
    </p>
    <table width="45%"  border="0" align="center" cellpadding="5" cellspacing="0" class="biaoge">
      <tr>
        <td colspan="2" class="right"><div align="center"><span class="style18">请输入根据提示问题输入问题答案</span></div></td>
      </tr>
      <tr>
        <td width="26%" class="left"><div align="right" class="style15">
          <div align="center">用户名</div>
        </div></td>
        <td width="74%" class="right"><?=$_POST[admin]?>
            <input name="id" type="hidden" id="id" value="<?=$rs["id"]?>" /></td>
      </tr>
      <tr>
        <td class="left"><div align="right" class="style15">
          <div align="center">密码提示</div>
        </div></td>
        <td class="right"><?=$rs["wt"]?></td>
      </tr>
      <tr>
        <td class="left"><div align="right" class="style16">
          <div align="center">问题答案</div>
        </div></td>
        <td class="right"><input name="da" type="text" class="wenben" id="da" /></td>
      </tr>
      <tr>
        <td colspan="2"><div align="left"> &nbsp;
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                             <input type="submit" name="Submit" value="提交" />
          &nbsp;&nbsp;&nbsp;  
          <input type="reset" name="Submit" value="重置" />
        </div></td>
      </tr>
    </table>
  </form>
   <?php
   }else{
     echo "<script language=javascript>";
  echo "alert('没有此用户,请确认你所输入的用户名是否正确!');";
  echo "javascript:history.go(-1);";
  echo "</script>"; //用javascript脚本提示用户;
}
   ?>
</body>

wangjimima2.php
<body>
<?php
   $sql = "select * from member where id=$_POST[id]";
   $result =mysql_query($sql,$connec);
  $rs =mysql_fetch_array($result);

 ?>
    <br />
  </p>
  <table width="80%"  border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td><div align="center"><span class="style12"><strong>恭喜您,您的密码以找回,请您紧记,切勿忘记!</strong></span></div></td>
    </tr>
  </table>
  <form action="wangjimima2.php" method="post" name="form2" id="form2">
    <table width="50%"  border="0" align="center" cellpadding="5" cellspacing="0" class="biaoge">
      <tr>
        <td colspan="2" class="right"><div align="center"><span class="style1 style12">这是您的用户名和密码,请勿忘记!</span></div></td>
      </tr>
      <tr>
        <td width="26%" class="left"><div align="center">用 户 名</div></td>
        <td width="74%" class="right">&nbsp;
            <?=$rs[admin]?></td>
      </tr>
      <tr>
        <td class="left"><div align="center">密&nbsp;&nbsp;&nbsp; 码</div></td>
        <td class="right">&nbsp;
            <?
       if ($_POST["da"]==$rs["da"]) {
          echo $rs["password"];
       session_register("admin");
       $admin=$rs[admin];
       $aaa=$rs[admin];
       
          }else{
       echo("<script type='text/javascript'> alert('对不起,您输入的密码提示答案错误!');location.href='wangjimima.php';</script>");

         }

       ?></td>
      </tr>
      <tr>
        <td colspan="2" class="left"><div align="center"><a href="index.php" class="c">返回首页</a></div></td>
      </tr>
    </table>
  </form>
</body>

会员修改资料
member_edit.php

<body>
<?php
$sql="select * from member where admin='$_GET[admin]'";
$conn=mysql_query($sql,$connec);
$rs=mysql_fetch_array($conn);
?>
<form action="member_edit_save.php" method="post" name="form3" id="form3">
  <table width="550"  border="1" align="center" cellpadding="0" cellspacing="0" class="biaoge">
    <tr>
      <td><table width="100%"  border="0" align="center" cellpadding="5" cellspacing="0">
        <tr>
          <td width="14%" class="left"><div align="center">用户名</div></td>
          <td width="86%" class="right"><input name="admin" type="text" class="wenben" id="admin" value="<?=$rs[admin]?>" size="15" />
                <input name="id" type="hidden" id="id" value="<?=$rs[id] ?>" />
            &nbsp;&nbsp;&nbsp;&nbsp;<span class="style11">不能小于4个字符(2个汉字)</span> </td>
        </tr>
        <tr>
          <td class="left"><div align="center">性别</div></td>
          <td class="right"><input type="radio" name="sex" value="男" <?php
                                                                    if ($rs[sex]==="男"){
                       echo "checked";
                       }
                        ?> />
            男&nbsp;
            <input name="sex" type="radio" value="女" <?php
                                                                    if ($rs[sex]==="女"){
                       echo "checked";
                       }
                        ?> />
            女&nbsp;&nbsp;&nbsp; <span class="style11">&nbsp;&nbsp;&nbsp; 请选择您的性别</span></td>
        </tr>
        <tr>
          <td rowspan="2" class="left"><div align="center">密码</div></td>
          <td class="right"><span class="style7">
            <input name="password" type="password" class="wenben" id="password" value="<?=$rs[password] ?>" size="20" />
            &nbsp;</span></td>
        </tr>
        <tr>
          <td class="right"><span class="style11"><span class="style7"> <span class="style12">最少6位</span></span>,请输入密码,区分大小写。不要使用类似 '*'、' '的特殊字符</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">确定密码</div></td>
          <td class="right"><input name="password1" type="password" class="wenben" id="password1" value="<?=$rs[password1] ?>" size="20" maxlength="16" />
                <span class="style11">&nbsp;&nbsp;&nbsp;&nbsp; 请再输一遍确认</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">密码问题</div></td>
          <td class="right"><input name="wt" type="text" class="wenben" id="wt" value="<?=$rs[wt] ?>" />
                <span class="style11">&nbsp;&nbsp; 忘记密码的提示问题</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">问题答案</div></td>
          <td class="right"><input name="da" type="text" class="wenben" id="da" value="<?=$rs[da] ?>" />
                <span class="style11">&nbsp;&nbsp; 忘记密码的提示问题答案,用于取回密码</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">QQ</div></td>
          <td class="right"><input name="qq" type="text" class="wenben" id="qq" value="<?=$rs[qq] ?>" size="20" maxlength="16" />
            &nbsp;&nbsp; <span class="style11">请输入你的QQ号</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">Emali</div></td>
          <td class="right"><input name="mail" type="text" class="wenben" id="mail" value="<?=$rs[mail] ?>" size="20" />
                <span class="style11">&nbsp;&nbsp; 请输入有效的邮件地址</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">邮政编码</div></td>
          <td class="right"><input name="youbian" type="text" class="wenben" id="youbian2" value="<?=$rs[youbian] ?>" size="7" maxlength="6" />
                <span class="style11">&nbsp;&nbsp;&nbsp; 请输入您所在地的邮政编码</span></td>
        </tr>
        <tr>
          <td class="left"><div align="center">联系电话</div></td>
          <td class="right"><input name="dianhua" type="text" class="wenben" id="dianhua" value="<?=$rs[dianhua] ?>" size="20" maxlength="15" />
                <span class="style7"><span class="style11">&nbsp;&nbsp; 格式0791-6274752</span></span></td>
        </tr>
        <tr>
          <td valign="top" class="left"><div align="center">家庭住址</div></td>
          <td class="right"><input name="dizhi" type="text" class="wenben" id="dizhi" value="<?=$rs[dizhi] ?>" size="40" />
                <span class="style11">&nbsp;&nbsp;&nbsp; 请输入您的住址</span></td>
        </tr>
        <tr>
          <td valign="top" class="left"><div align="center">个性签名</div></td>
          <td class="right"><textarea name="qianming" cols="40" rows="4" id="qianming"><?=$rs[qianming] ?>
</textarea></td>
        </tr>
        <tr>
          <td valign="top" class="left"><div align="center">个人说明</div></td>
          <td class="right"><textarea name="textarea" cols="40" rows="8"><?=$rs[textarea] ?>
</textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;
                <input type="submit" name="Submit" value="提交" />
            &nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;&nbsp; &nbsp;
            <input type="reset" name="Submit2" value="重置" /></td>
        </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
member_edit_save.php
<?php
require_once("conn.php");

$admin=check_form($_POST[admin]);
$password=check_form($_POST[password]);
$password1=check_form($_POST[password1]);
$qq=check_form($_POST[qq]);
$youbian=check_form($_POST[youbian]);
$mail=check_form($_POST[mail]);
$textarea=check_form($_POST[textarea]);

if ($admin=="" or (strlen($admin)>16) or (strlen($admin)<2)) {
     echo "<SCRIPT language=JavaScript>alert('请输入用户名(不能大于16小于2)');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
}

if ($password=="" or strlen($password)>16 or strlen($password)<6) {
     echo "<SCRIPT language=JavaScript>alert('密码长度为6-16个字符');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
}

if ($password=="") {
     echo "<SCRIPT language=JavaScript>alert('确认密码不能为空');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
}else{
 if ($password!=$password1) {
     echo "<SCRIPT language=JavaScript>alert('密码和确认密码不一致');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
 }
}

if ($qq!="") {
  if (!is_numeric($qq)) {
     echo "<SCRIPT language=JavaScript>alert('QQ号码必须是数字');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
  }
}

if ($youbian=="" or strlen($youbian)!=6)  {
     echo "<SCRIPT language=JavaScript>alert('请正确输入邮编');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
}

if ($youbian!="") {
  if (!is_numeric($youbian)) {
     echo "<SCRIPT language=JavaScript>alert('邮编必须是数字');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
  }
}

if ($dizhi!="") {
  if (!is_numeric($dizhi)) {
     echo "<SCRIPT language=JavaScript>alert('住址不能为空');";
     echo"this.location.href='vbscript:history.back()';</SCRIPT>";
    
  }
}

if ($mail=="") {
 echo "<SCRIPT language=JavaScript>alert('E-mail不能为空!');";
 echo "this.location.href='vbscript:history.back()';</SCRIPT>";
 

if ($textarea=="") {
 echo "<SCRIPT language=JavaScript>alert('个人说明不能为空!');";
 echo "this.location.href='vbscript:history.back()';</SCRIPT>";
 
}

if ($textarea=="" or strlen(textarea)>150 ) {
   echo "<SCRIPT language=JavaScript>alert('个人说明为150个字符');";
   echo"this.location.href='vbscript:history.back()';</SCRIPT>";
  
}
//===================验证表单内容是否合法(结束)======================


//===============================验证是否有重复申请(开始)===============

$sql="select * from member where admin='$_POST[admin]'";
$conn=mysql_query($sql,$connec);

if ($rs=mysql_fetch_array($conn)) {
echo "<script language=javascript>";
echo "alert('已经有此用户了!');";
echo "javascript:history.go(-1);";
echo "</script>";

}else{
$sql="select * from member where qq='$_POST[qq]'";
$conn=mysql_query($sql,$connec);

  if ($rs=mysql_fetch_array($conn)) {
  echo "<script language=javascript>";
  echo "alert('同一用户只可申请一个!');";
  echo "javascript:history.go(-1);";
  echo "</script>";
 
 } else{
        $sql="select * from member where mail='$_POST[mail]'";
  $conn=mysql_query($sql,$connec);

         if ($rs=mysql_fetch_array($conn)) {
         echo "<script language=javascript>";
         echo "alert('同一用户只可申请一个!');";
         echo "javascript:history.go(-1);";
         echo "</script>";
        
        } else{
//========================验证是否有重复申请(结束)以下是将表单的内容插入到数据库中============================

$sql="update member set admin='$_POST[admin]',sex='$_POST[sex]',password='$_POST[password]',qq='$_POST[qq]',youbian='$_POST[youbian]',dizhi='$_POST[dizhi]',dianhua='$_POST[dianhua]',mail='$_POST[mail]',qianming='$_POST[qianming]',textarea='$_POST[textarea]',wt='$_POST[wt]',da='$_POST[da]',date='date()' where id='$_GET[id]'";
mysql_query($sql,$connec);
echo("<script type='text/javascript'> alert('修改成功!');location.href='index.php';</script>");

}
  }
         }
?>

posted @ 2012-06-01 21:40  暮色灯塔  阅读(914)  评论(0编辑  收藏  举报