我们在运营含有会员系统的网站前期,由于注册会员比较少,或者限制了会员自主注册功能,就需要管理员在后台直接添加会员。织梦默认后台是不能添加会员的。六久阁做了以下二次开发。可以支持在后台直接添加会员。
开发方法
1、需要新增两个文件: huiyuan_add.php 和 huiyuan.htm。huiyuan_add.php放在 /dede/文件夹下,huiyuan_add.htm放在/dede/templets/文件夹下。
huiyuan_add.php 代码如下:
<?php require(dirname(__FILE__)."/config.php"); $ENV_GOBACK_URL = "member_main.php"; if($dopost=="add"){ $jointime = $logintime = time(); $loginip = $joinip = GetIP(); $dsql->ExecuteNoneQuery("INSERT INTO dede_member SET `mtype`='$mtype',`userid`='$userid',`pwd`='$password',`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); exit(); } else{ include DedeInclude('templets/huiyuan_add.htm'); } ?>
huiyuan_add.htm 的代码如下:
<html> <head> <meta http-equiv='Content-Type' content='text/html; charset=gb2312'> <title>添加会员</title> <link href="css/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> >> 添加会员</td> </tr> <tr> <td height="200" bgcolor="#FFFFFF" align='center'> <table width="98%" border="0" cellspacing="0" cellpadding="6" > <tr> <td colspan="2" height="10" ></td> </tr> <form name="form2" action="huiyuan_add.php" method="post" onSubmit="return checkSubmit();"> <input type="hidden" name="dopost" value="add" /> <tr> <td width="17%" align="right" class='bline'>用户名:</td> <td width="83%" 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'> <?php echo $row['mtype']; ?> <input type="radio" name="mtype" class="np" value="个人" checked='1'/> 个人 <input type="radio" name="mtype" class="np" value="企业" />企业 </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'/> 男 <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:180px'>\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" > </td> <td height="67" > <input type="submit" name="Submit" value="确定添加" class='coolbg' /> <input type="reset" name="Submit22" value="重置表单" class='coolbg' /> </td> </tr> </form> </table> </td> </tr> </table> </body> </html>
打开 dede\inc\inc_menu.php,找到
<m:item name='注册会员列表' link='member_main.php' rank='member_List' target='main' />
在其 下面 增加如下代码
<m:item name='添加会员' link='huiyuan_add.php' rank='huiyuan_Add' target='main' />
完成。
织梦二次开发QQ群
本站客服QQ号:862782808(点击左边QQ号交流),群号(383578617) 如果您有任何织梦问题,请把问题发到群里,阁主将为您写解决教程!
转载请注明: 织梦模板 » 织梦后台直接添加会员功能开发方法