如何在网站上加入用户注册功能

如何在网站上加入用户注册功能,第1张

这个需要涉及数据库的维护和使用以及网页编程的应用

一般建议你去用别人的做好的,自己一个人做工作量太大。

如www.discuz.net这个网站,到里面找supersite就可以了,

补充:supersite这个东西你去点下载,一样可以用,不用破解的,因为他给免费授权。

supersite用mysql数据库管理用户

你可以在安装了supersite以后用管理员帐户进入后台对用户进行管理

很好的

第一步:首先做一个如下页面。

<html>

<head>

<title>申请帐号</title>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312">

<style type="text/css">

<!--

.p11 { font-size: 10ptcolor: #000000text-decoration: none}

.c3a {font-size: 9ptcolor: #000000background-color: #ffffffborder: 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: 10ptcolor: #EFFB00background-color: rgb(225,153,0)">

<input type="reset" name="Submit2" value="重来" style="font-size: 10ptcolor: #EFFB00background-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/htmlcharset=gb2312">

<style type="text/css">

<!--

.p11 { font-size: 10ptcolor: #000000text-decoration: none}

.c3a {font-size: 9ptcolor: #000000background-color: #ffffffborder: 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: 10ptcolor: #EFFB00background-color: rgb(225,153,0)">

<input type="reset" name="Submit2" value="重来" style="font-size: 10ptcolor: #EFFB00background-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>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/bake/11660749.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存