织梦后台添加会员功能

一共包含三个文件,都放在后台目录中

菜单项添加

找到后台inc文件夹下的inc_menu.php文件中的这段
<m:top item='6_' name='会员管理' display='none' rank='member_List,member_Type'>
  <m:item name='注册会员列表' link='member_main.php' rank='member_List' target='main' />
在下面或某一处添加
<m:item name='添加会员' link='member_add.php' rank='member_Add' target='main' />

member_add.php文件

将以下内容保存为此文件,并放在织梦后台根文件夹里,如后台是dede,那么就放在dede里面。
<?php
require(dirname(__FILE__)."/config.php");
$ENV_GOBACK_URL = isset($_COOKIE['ENV_GOBACK_URL']) ? "member_main.php" : '';
if($dopost=="add")
{
$jointime = $logintime = time();
$loginip = $joinip = GetIP();
$pwd = md5($pwd);
$dsql->ExecuteNoneQuery("INSERT INTO dede_member SET `mtype`='$mtype',`userid`='$userid',`pwd`='$pwd',`uname`='$uname',`sex`='$sex' ,`rank`='$rank',`money`='$money', `email`='$email', `scores`='$scores', `matt`='0', `face`='',`safequestion`='0',`safeanswer`='$safeanswer', `jointime`='$jointime',`joinip`='$joinip',`logintime`='$logintime',`loginip`='$loginip'");
ShowMsg('成功添加一个用户',$ENV_GOBACK_URL);
}

else include DedeInclude('templets/member_add.htm');
?>

会员添加模板文件

文件名member_add.htm,放在后台templets文件夹中
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>无标题文档</title>
<link href='img/base.css' rel='stylesheet' type='text/css'>
<script language='javascript'src='../data/enums/area.js'></script>
<script>
function checkSubmit()
{
  if(document.form2.email.value=="")
  {
    document.form2.email.focus();
    alert("Email不能为空!");
    return false;
  }
  if(document.form2.uname.value=="")
  {
    document.form2.uname.focus();
    alert("用户昵称不能为空!");
    return false;
  }
}
</script>
</head>
<body background='img/allbg.gif' leftmargin='8' topmargin='8'>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#D1DDAA">
  <tr>
    <td height="19" background="img/tbg.gif"><a href='<?php echo $ENV_GOBACK_URL; ?>'><b>会员管理
 
</b></a> &gt;&gt; 添加会员</td>
</tr>
<tr>
<td height="200" bgcolor="#FFFFFF">
 
<table width="98%" border="0" cellspacing="0" cellpadding="6" >
        <tr>           <td colspan="2" height="10" ></td>
        </tr>
        <form name="form2" action="member_add.php" method="post" onSubmit="return checkSubmit();">
          <input type="hidden" name="dopost" value="add" />
          <tr>             <td width="15%" align="right" class='bline'>用户名:</td>
            <td width="85%" class='bline'>  <input name="userid" type="text" value="" id="userid" size="20"  
style="width:150px;height:20px" />
            </td>
          </tr>
          <tr>             <td align="right" class='bline'>密 码:</td>
            <td class='bline'>
            <input type="text" name="pwd" id="pwd" />
            </td>
          </tr>
 
          <tr>             <td align="right" class='bline'>用户类型:</td>
            <td class='bline'>
          
           <input type="radio" name="mtype" class="np" value="个人"  
checked='1'/>
              个人 &nbsp;   
            </td>
          </tr>
          <tr>             <td align="right" class='bline'>电子邮箱:</td>
            <td class='bline'>
            <input name="email" type="text" id="email" value="<?php echo $row['email']?>"  
style="width:150px;height:20px" />
            </td>
          </tr>
          <tr>             <td align="right" class='bline'>昵 称:</td>
            <td class='bline'>
            <input name="uname" type="text" value="<?php echo $row['uname']?>" id="uname" size="20"  
style="width:150px;height:20px" />
           </td>
          </tr>
          <tr><td align="right" class='bline'>性 别:</td>
            <td class='bline'>
            <input type="radio" name="sex" class="np" value="男"  checked='1'/>
              男 &nbsp;              <input type="radio" name="sex" class="np" value="女" />
              女
             <input type="radio" name="sex" class="np" value="" />
              保密
             </td>
          </tr>
 
          <tr>             <td align="right" class='bline'>等级:</td>
            <td class='bline'><?php
             $MemberTypes = '';
             $dsql->SetQuery("Select rank,membername From `dede_arcrank` where rank>0");
             $dsql->Execute('n');
             $MemberTypes[0] = "限制会员";
             while($nrow = $dsql->GetObject('n')){
             $MemberTypes[$nrow->rank] = $nrow->membername;
             }
             $options = "<select name='rank' style='width:80px'>\r\n";
             foreach($MemberTypes as $k=>$v)
             {
             if($k!=$row['rank']) $options .= "<option value='$k'>$v</option>\r\n";
             else $options .= "<option value='$k' selected>$v</option>\r\n";
             }
             $options .= "</select>\r\n";
echo $options;
?></td>
          </tr>
          <tr>             <td height="67" align="right" >&nbsp;</td>
            <td height="67" >
            <input type="submit" name="Submit" value="确定添加" class='coolbg' />               &nbsp;&nbsp;
            <input type="reset" name="Submit22" value="重置表单" class='coolbg' />
            </td>
          </tr>
        </form>
    </table>
    </td>
</tr>
</table>
</body>
</html>

经测试,百分百可行。
这个功能主要优点是,不让用户在前台注册,要管理员后台来添加,然后在把账号给用户。以防止会员漏洞出现时,别人批量扫描拿下网站。

评论

大侠名号:   验证码: 点击我更换图片  

修远兮

在这里记录每一点自己需要的知识

添加创始人微信,一起交流心得

推荐文章RECOMMEND