日期:2014-05-17  浏览次数:20935 次

我用ASP写了个注册页面,运行时不报错,但是不能把数据写入数据库
代码是这样的

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!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">
<!-- #include file="db.inc.asp"-->
<!-- #include file="config/function.inc.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户注册</title>
<style type="text/css">
#apDiv1 {
width:600px;
height:800px;
z-index:1;
left: 243px;
top: 61px;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
body {
margin-top: 0px;
background-color: #FFF;
}
#apDiv2 {
position:absolute;
width:600px;
height:500px;
z-index:1;
background-color: #FFFFFF;
background-image: url(images/regbg.jpg);
}
#apDiv3 {
position:absolute;
width:400px;
height:266px;
z-index:2;
left: 102px;
top: 114px;
background-color: #FFFFFF;
text-align: center;
}

.regtd {
text-align: right;
}
.red {
color: #F00;
}
table{
  border-collapse: collapse;
border: none;
height: 189px;
width: 358px;
}
td 
{
border: 1px solid #000;

.zdq {
text-align: left;
}
</style>
</head>

<body>
<%
on error resume next
dim sql,rst
if request.QueryString("act")="reg" then
  if request.form("f_user")="" or request.form("f_code")="" then
  msgboxU "用户名和密码不能为空!"
  else
  set rst=server.CreateObject("adodb.recordset")
sql="select count(*) as recnum from tbl_user where u_user='"&request.form("f_user")&"'"
  rst.open sql,conn,1,1
if rst("recnum")>0 then 
msgboxU "已存在同名用户!"
else 
sql2="insert into tbl_user(u_user,u_code,u_name,u_sex,u_tel,u_mail) values('"&request.form("f_user")&"','"&request.form("f_code")&"','"&request.form("f_name")&"','"&request.form("f_sex")&"','"&request.form("f_tel")&"','"&request.form("f_tel")&"')"
conn.execute(sql2)  
  set myErr=conn.errors
if myErr=0 then
msgboxU"注册成功"
else 
msgboxU"注册失败! 原因:" & myErr.item(0).description
end if

end if
rst.close
ser.rst=nothing
end if
end if
%>

<div id="apDiv1">
  <div id="apDiv2">
  <div id="apDiv3">
  <form id="form1" name="form" method="post" action="register.asp?act=reg">
  <table> 
  <tr>
  <td colspan="3" class="zdq">请在下面填写注册信息,带<span class="red">*</span>为必填内容</td>
  </tr>
  <tr>
  <td width="103" align="right">用户名:</td>
  <td width="167" class="zdq">
  <input name="f_user" type="text" id="user"