分享关于asp注册代码实例

互联网 17-6-17
用户注册是很多网站都必须用的功能,实现注册方法很多,今天我就把我方法拿出来共享一下吧,我把注册填表文件,与判断保存数据文件分开,reg.htm 与reg.asp,这样做的好处很多,我想这个不用我多说了吧,看了我以前的文章都应该知道了,我的文章在www.111cn.net里面有很多,下面看代码.reg.htm,效果图我就不贴了,
<table width="100%"border="0" cellpadding="0" cellspacing="0">    <tr>      <td width="250" height="77" ><div align="center"></div></td>      <td >&nbsp;</td>      <td width="300"><div align="right"><a href="x_wai_chuli.asp?xlei=newman"></a></div></td>    </tr>  </table>  <div  style="position: relative; top:80px; width:400px; height:300px; left:30%">            <table width="600" border="0" cellpadding="0" cellspacing="0">     <form id="form1" name="form1" method="post" action="singin.asp">        <tr>        <td height="50">&nbsp;</td>        <td height="50"><div align="center"><font color="#B4CFED" size="3"><b>用户注册</b></font></div></td>        <td height="50">&nbsp;</td>      </tr>      <tr>        <td width="118" height="40"><div align="right"><b><font color="#FFFFFF">学号:</font></b></div></td>        <td width="210"><table width="200" border="0" cellspacing="0" cellpadding="0">          <tr>            <td width="5"><img src="skins/input1.png" width="5" height="25" /></td>            <td background="skins/input3.png"><input name="myname" type="text" id="myname" style="border:solid 0px;" /></td>            <td width="6"><img src="skins/input2.png" width="6" height="25" /></td>          </tr>        </table></td>        <td width="272"><a href="index.asp">我有帐号了,登录?</a></td>      </tr>      <tr>        <td height="40"><div align="right"><b><font color="#FFFFFF">密 码:</font></b></div></td>        <td><table width="200" border="0" cellspacing="0" cellpadding="0">          <tr>            <td width="5"><img src="skins/input1.png" width="5" height="25" /></td>            <td background="skins/input3.png"><input name="mypass" type="password" id="mypass" style="border:solid 0px;" /></td>            <td width="6"><img src="skins/input2.png" width="6" height="25" /></td>          </tr>        </table></td>        <td align="left">&nbsp;</td>      </tr>      <tr>        <td height="40"><div align="right"><b><font color="#FFFFFF">确认密码:</font></b></div></td>        <td><table width="200" border="0" cellspacing="0" cellpadding="0">          <tr>            <td width="5"><img src="skins/input1.png" width="5" height="25" /></td>            <td background="skins/input3.png"><input name="mypass2" type="password" id="mypass2" style="border:solid 0px;" /></td>            <td width="6"><img src="skins/input2.png" width="6" height="25" /></td>          </tr>        </table></td>        <td>&nbsp;</td>      </tr>      <tr>        <td height="40"><div align="right"><b><font color="#FFFFFF">学生名称:</font></b></div></td>        <td><table width="200" border="0" cellspacing="0" cellpadding="0">          <tr>            <td width="5"><img src="skins/input1.png" width="5" height="25" /></td>            <td background="skins/input3.png"><input name="stuname" type="text" id="stuname" style="border:solid 0px;" /></td>            <td width="6"><img src="skins/input2.png" width="6" height="25" /></td>          </tr>        </table></td>        <td>&nbsp;</td>      </tr>      <tr>        <td height="40">&nbsp;</td>        <td><label>          <input name="button" type="submit" class="nnt_submit" id="button" value="注册" />        </label>          <a href="x_reg.asp">          <label>          <input name="button2" type="reset" class="nnt_submit" id="button2" value="重置" />          </label>          </a></td>        <td>&nbsp;</td>      </tr></form>    </table>

这是reg.htm的代码全是htm的不讲了,不过要提示一下,最好在客户端进行判断,用户输入数据的合法性,这样有利于用户体验,这里我不写了,我在php实现·php 用户登陆里面详细的写了,

下面来看reg.asp的代码

<!--#include file="inc/cn.asp" -->  <!--#include file="inc/function.asp" -->  <%   myname =Html_encode(Request.Form("myname"))   mypass =Html_encode(Request.Form("mypass"))   mypass2 =Html_encode(Request.Form("mypass2"))   stuname =Html_encode(Request.Form("stuname"))      If myname="" or mypass="" or mypass<>mypass2 or stuname="" Then    Response.Write("<script>alert('请认真填写你的信息!');history.back();</script>")   Elseif len(myanme)>15 or len(mypass)>15 or len(stuname)>5 or len(stuname)<2Then    Response.Write("<script>alert('你输入信息的长度不对,用户名密码长度1-15位,姓名长度2-5位');history.back();</script>")   Else    Sql="select * from stu_user where user_id='"&myname&"'"    Call Db_connect()    Rs.open Sql,conn,1,3    If  Rs.eof Then     Rs.addnew     Rs("user_id")=myname     Rs("user_dj")="0"     Rs("User_name")=stuname     Rs("user_pwd")=mypass2     Rs.update     Session("Uid")=myname     Session("Udj")="0"     Session("Stuname")=stuname     Response.Redirect("iframe.asp")        Else     Response.Write("<script>alert('你的学号己被注册,请联系管理员再试!');history.back();</script>")    End if   End If     %>

简单吧,

以上就是分享关于asp注册代码实例的详细内容,更多内容请关注技术你好其它相关文章!

来源链接:
免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
标签: 注册
上一篇:php获取远程图片并下载保存到本地的方法分析 下一篇:C#怎么将 HTML转换为图片或 PDF?

相关资讯