设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 52|回复: 1
打印 上一主题 下一主题

[原创]asp+access改成asp+mssql后发生的问题.请大家帮忙.急!!!!!!!!!!!!谢谢 ...

[复制链接]
跳转到指定楼层
1#
发表于 2010-1-13 00:32:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
信息输入页面:userreg2.asp ---------------------------------------------------- <%PageName="UserReg2"%> <!--#include file="conn.asp"--> <!--#include file="const.asp"--> <!--#include file="top.asp"--> <!--#include file=function.asp -->
<table cellpadding=0 cellspacing=0 border=0 width=<%=TableWidth%> bgcolor=<%=MainBgColor%> align=center> <FORM name=reg2 action=UserRegPost.asp method=post> <TR> <%=OutTable("left")%> <td align=center> <table border=0 cellpadding=0 cellspacing=0 width=200> <tr> <td><br> <fieldset width=20%> <legend align=center>| 新会员注册 |</legend> <table border=0 cellpadding=0 cellspacing=0 width=400 bgcolor=<%=MainCColor%>> <tr> <TD width=30% align=right>**注册名:</TD> <TD><INPUT maxLength=20 size=16 name=UserName> (可以使用中英文匿名)</TD> </TR> <TR> <TD align=right>**密 码:</TD> <TD><INPUT type=password maxLength=20 size=16 name=password></TD> </TR> <TR> <TD align=right>**密码确认:</TD> <TD><INPUT type=password maxLength=20 size=16 name=password2></TD> </TR> <TR> <TD align=right>**Email地址:</TD> <TD><INPUT size=30 name=Email></TD> </TR> <TR> <TD align=right>性 别:</TD> <TD><INPUT type=radio checkED value="1" name=sex> 男 <INPUT type=radio value="0" name=sex> 女</TD> </TR> <TR> <TD align=right>OICQ号码:</TD> <TD><INPUT size=20 name=OICQ></TD> </TR> <TR> <TD align=right>主页名称:</TD> <TD><INPUT size=30 name=UserWebName></TD> </TR> <TR> <TD align=right>主页地址:</TD> <TD><INPUT size=30 name=UserWebUrl value="http://"></TD> </TR> <TR> <TD align=right>签 名:</TD> <TD><TEXTAREA name=MyIntro rows=5 wrap=PHYSICAL cols=40></TEXTAREA></TD> </TR> <TR align=center> <TD colspan=2 height=30><INPUT value="注 册" name=Submit type=submit> <INPUT type=reset value="重 写" name=Submit2></TD> </TR> </TABLE> </fieldset> </td> </tr> </table> <br> </td> <%=OutTable("right")%> </tr> </FORM> </table> <%set rs=nothing%><!--#include file="copyright.asp"--> ---------------------------------------------------------------------------------- 将输入的数据传到UserRegPost.asp 代码如下: ------------------------------------------------- <%PageName="UserRegPost"%> <!--#include file="conn.asp"--> <!--#include file="const.asp"--> <!--#include file="session.asp"--> <!--#include file="INC/CHAR.INC"--> <!--#include file=function.asp -->
<%
founderr=false
if request.form("UserName")="" or len(request.form("UserName"))>20 then errmsg=errmsg+"<li>用户名输入错误(未输入或长度超过了20个字节)。" founderr=true else UserName=trim(request.form("UserName")) end if if request.form("sex")="" then errmsg=errmsg+"<li>请选择您的性别。" founderr=true elseif left(UserName,3)="%20" OR InStr(UserName,"=")<>0 or InStr(UserName,"`")<>0 or InStr(UserName," ")<>0 or InStr(UserName," ")<>0 or InStr(UserName,"'")<>0 or InStr(UserName,chr(34))<>0 or InStr(UserName,"\")<>0 or InStr(UserName,",")<>0 or InStr(UserName,"<")<>0 or InStr(UserName,">")<>0 or InStr(UserName,"&lt;")<>0 or Instr(UserName,"&gt;") or UserName="大家" or Instr(UserName,"爱雪") or UserName="无" or Instr(UserName,"爸") or Instr(UserName,"妈") or Instr(UserName,"娘") or Instr(UserName,"爷") or Instr(UserName,"奶") or Instr(UserName,"老子") or Instr(UserName,"你") or Instr(UserName,"他") or Instr(UserName,"她") or UserName="站长" or UserName="root" or UserName="administrator" or UserName="admin" or UserName="sex" then errmsg=errmsg+"<li>你输入的帐号非法,可能有非法的字符或字符串。" founderr=true elseif request.form("sex")=0 or request.form("sex")=1 then sex=request.form("sex") else errmsg=errmsg+"<li>您输入的字符非法。" founderr=true end if if request.form("password")="" or Len(request.form("password"))>20 then errmsg=errmsg+"<li>请输入您的密码(长度不能大于20)。" founderr=true else password=request.form("password") end if if password<>request("password2") then errmsg=errmsg+"<li>您输入的密码和确认密码不一致。" founderr=true end if if IsValidEmail(trim(request.form("Email")))=false then errmsg=errmsg+"<li>您的Email有错误。" founderr=true else Email=trim(request.form("Email")) end if
if trim(request.form("UserWebName"))<>"" then if trim(request.form("UserWebUrl"))="" or trim(request.form("UserWebUrl"))="http://" then errmsg=errmsg+"<li>您输入了网站名称,但是没有输入网站地址。" founderr=true end if else if trim(request.form("UserWebUrl"))<>"" or trim(request.form("UserWebUrl"))="http://" then errmsg=errmsg+"<li>您没有输入网站名称,但是您输入了网站地址。" founderr=true end if end if
if founderr=true then call error() else set rs=server.createobject("adodb.recordset") sql="select * FROM Users where username='"&username&"'" rs.open sql,conn,1,3 if not rs.eof or username=WebTitle then errmsg="<br>"+"<li>对不起,您输入的用户名已经被注册,请重新输入。" founderr=true else rs.addnew rs("username")=username rs("password")=password rs("email")=email if request.form("MyIntro")<>"" then rs("sign")=htmlencode2(trim(request.form("MyIntro"))) if request.form("oicq")<>"" then rs("oicq")=request.form("oicq") if request.form("UserWebName")<>"" and request.form("UserWebUrl")<>"" then rs("UserWebName")=request("UserWebName") rs("UserWebUrl")=request("UserWebUrl") end if if RegFree=1 then rs("IsChecked")=1 else rs("IsChecked")=0 end if Rs("sex")=sex Rs("addDate")=now() rs("logins")=0 Rs("lastlogin")=now() rs("UserLevel")=1 rs("UserPoint")=0 rs.update end if rs.close
if founderr=true then call error() else %>
<!--#include file="top.asp"--> <table cellpadding=0 cellspacing=0 border=0 width=<%=TableWidth%> bgcolor=<%=MainBgColor%> align=center> <tr> <%=OutTable("left")%> <td align=center> <br> <table border="1" width="50%" align="center" cellspacing="0" cellpadding="5" class="TableLine" bordercolorlight="<%=MainBColor%>"> <tr > <td colspan=2 align="center" height=24 bgcolor=<%=MainTColor%>><b>会员注册成功</b></td> </tr> <tr> <td width=22% align=right>注 册 名</td> <td width="78%"><%=username%></td> </tr> <tr> <td align=right width="22%">性 别</td> <td width="78%"> <%if sex=1 then%> 男 <%else%> 女 <%end if%> </td> </tr> <tr> <td align=right width="22%">密 码</td> <td width="78%"><%=password%> </td> </tr> <tr> <td align=right width="22%">Email地址</td> <td width="78%"><%=email%> </td> </tr> <tr> <td align=right width="22%">OICQ号码</td> <td width="78%"> <%if request.form("oicq")="" then%> 未填写 <%else%> <%=request.form("oicq")%> <%end if%> </td> </tr> <tr> <td align=right width="22%">主页</td> <td width="78%"> <%if request.form("UserWebUrl")="" or request.form("UserWebName")="" then%> 未填写 <%else%><a href="<%=request.form("UserWebUrl")%>" target=_blank> <%=request.form("UserWebName")%> </a> <%end if%> </td> </tr> <tr> <td align=right width="22%">会员积分</td> <td width="78%">0</td> </tr> <tr> <td align=right width="22%">会员等级</td> <td width="78%"><%=Level(1)%> </td> </tr> <tr> <td align=right valign=top width="22%">签 名</td> <td width="78%"> <%if trim(request.form("MyIntro"))="" then%> 未填写 <%else%> <%=htmlencode2(trim(request.form("MyIntro")))%> <%end if%> </td> </tr> <tr> <td align=center colspan=2><%if RegFree=0 then%>请耐心等待管理员的认证<%else%><a href=UserLogin.asp>请登陆</a><%end if%></td> </tr> </table> <br></td> <%=OutTable("right")%> </tr> </table> <% set rs=nothing %> <!--#include file="copyright.asp"--> <% end if end if %> ------------------------- 通过上面这个页面数据应该写入到mssql数据库中,但是就是不能写入.我认为以下语句有问题 rs.addnew rs("username")=username rs("password")=password rs("email")=email if request.form("MyIntro")<>"" then rs("sign")=htmlencode2(trim(request.form("MyIntro"))) if request.form("oicq")<>"" then rs("oicq")=request.form("oicq") if request.form("UserWebName")<>"" and request.form("UserWebUrl")<>"" then rs("UserWebName")=request("UserWebName") rs("UserWebUrl")=request("UserWebUrl") end if if RegFree=1 then rs("IsChecked")=1 else rs("IsChecked")=0 end if Rs("sex")=sex Rs("addDate")=now() rs("logins")=0 Rs("lastlogin")=now() rs("UserLevel")=1 rs("UserPoint")=0 rs.update end if rs.close ------------------------------------------------------------------ 我应该怎么去做才可以写入数据到mssql数据库?此源码在access数据库下一切正常.请各位帮忙.急!!!!!!!!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 08:41 , Processed in 0.099209 second(s), 8 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表