| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 517 人关注过本帖
标题:[求助]请高手帮忙,我的ASP向数据库写不入数据???
只看楼主 加入收藏
二胡
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2005-12-16
收藏
 问题点数:0 回复次数:0 
[求助]请高手帮忙,我的ASP向数据库写不入数据???

我把用户注册页面和写入数据库页面的代码附上,请各位高手指点!多谢!!!
<!-- 用户信息填写 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>茶频道:用户注册信息</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
background-color: #FFFFFF;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style1 {
color: #660033;
font-size: 13px;
}
.style2 {color: #FF0000}
.style5 {
font-family: "华文行楷";
color: #CCCCCC;
}
.style6 {color: #996600}
.style8 {color: #000099}
.style9 {color: #000000}
.style11 {color: #333333}
.style35 {color: #3399FF}
.style37 {
font-family: "楷体_GB2312";
color: #666600;
}
-->
</style>
<SCRIPT language=javascript>
<!--
function checkform()
{
if (document.registerform.name.value==""){
alert("请输入用户名!");
document.registerform.name.focus();
return false;
}
if (document.registerform.password.value==""){
alert("请输入密码!");
document.registerform.password.focus();
return false;
}
if (document.registerform.password2.value==""){
alert("请输入确认密码!");
document.registerform.password2.focus();
return false;
}
if (document.registerform.sex.value==""){
alert("请选择性别!");
document.registerform.sex.focus();
return false;
}
if (document.registerform.qq.value==""){
alert("请输入QQ号码!");
document.registerform.qq.focus();
return false;
}
if (document.registerform.email.value==""){
alert("请输入E-mail!");
document.registerform.email.focus();
return false;
}
if (document.registerform.question.value==""){
alert("请输入密码保护问题!");
document.registerform.question.focus();
return false;
}
if (document.registerform.answer.value==""){
alert("请输入密码保护问题!");
document.registerform.answer.focus();
return false;
}
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</SCRIPT>
</head>

<body>
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><img src="images/banner.gif" width="600" height="60"></div></td>
</tr>
</table>
<br>
<table width="750" border="0" align="center" cellpadding="1" cellspacing="2">
<tr>
<td width="300" valign="top"><table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td><strong>茶频道会员注册步骤:</strong></td>
</tr>
<tr>
<td><span class="style9">1、阅读用户注册申明条款</span><br>
<span class="style2"><em>2、填写注册信息</em></span><br>
3、完成注册 </td>
</tr>
<tr>
<td><strong>广告展示区:</strong>(<strong>110*50</strong>)</td>
</tr>
<tr>
<td><div align="left"><img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"> </div></td>
</tr>
</table></td>
<td width="450"><form action="check.asp" method="post" name="registerform" id="registerform" onsubmit="return checkform();">
<table width="100%" border="1" cellpadding="2" cellspacing="2" bordercolor="#66FF00">
<tr>
<td colspan="2"><img src="images/3.gif" width="30" height="30" align="absmiddle"><span class="style1">用户注册信息</span></td>
</tr>
<tr bgcolor="#66CC00">
<td colspan="2"><span class="style2">说明:</span><span class="style5">为了更好的为您服务,更准确、更及时的与您联系,请您务必详细填写您的信息,并核对无误!请放心,您的资料未经过您的允许,我们不将对外透露!<span class="style6">带*号的为必填项。</span></span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">姓名:<span class="style2">*</span></div></td>
<td width="320"><input name="name" type="text" id="name" size="30" maxlength="15">
<span class="style37">4-8个字符</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">密码:<span class="style2">*</span></div></td>
<td width="320"><input name="password" type="password" id="password" size="33" maxlength="35">
<span class="style37">6个以上字符</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">确认密码:<span class="style2">*</span></div></td>
<td width="320"><input name="password2" type="password" id="password2" size="33" maxlength="35"></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">性别:<span class="style2">*</span></div></td>
<td width="320"><input name="sex" type="radio" value="0" checked>

<input type="radio" name="sex" value="1">
女</td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">年龄:</div></td>
<td width="320"><input name="age" type="text" id="age" size="30" maxlength="3">
<span class="style37">可以保密</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">QQ:<span class="style2">*</span></div></td>
<td width="320"><input name="qq" type="text" id="qq" size="30" maxlength="10">
<span class="style37">QQ号码</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">E-mail:<span class="style2">*</span></div></td>
<td width="320"><input name="email" type="text" id="email" size="30" maxlength="30">
<span class="style37">邮件地址</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">联系电话:</div></td>
<td width="320"><input name="phone" type="text" id="phone" size="30" maxlength="12">
<span class="style37">可以保密</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">联系地址:</div></td>
<td width="320"><input name="address" type="text" id="address" size="30" maxlength="50">
<span class="style37">可以保密</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">学历:</div></td>
<td width="320"><select name="education" size="1" id="education">
<option value="0">小学</option>
<option value="1">中学</option>
<option value="2">中专</option>
<option value="3">大学专科</option>
<option value="4" selected>大学本科</option>
<option value="5">硕士研究生</option>
<option value="6">博士生</option>
<option value="7">其他</option>
</select></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">密码问题:<span class="style2">*</span></div></td>
<td width="320"><input name="question" type="text" id="question" size="30" maxlength="30">
<span class="style37">取回密码问题</span></td>
</tr>
<tr>
<td width="80" bgcolor="#66CC00"><div align="left" class="style8">回答问题:<span class="style2">*</span></div></td>
<td width="320"><input name="answer" type="text" id="answer" size="30" maxlength="30">
<span class="style37">取回密码答案</span></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="确定">
<input type="reset" name="Submit2" value="取消">
</div></td>
</tr>
</table>
</form>
<div align="center"><br>
<img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"><img src="images/2.gif" width="110" height="50"></div></td>
</tr>
</table>
<hr width="650">
<table width="750" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">Copyright:&copy;2005-2008 版权所有:&reg;茶频道 制作维护:二胡工作室 网站宗旨:<span class="style11"><span class="style35"><img src="images/1.gif" width="150" height="15" align="absmiddle"></span></span><br>
<a href="images/logo.htm" target="_blank"><img src="images/logo.jpg" alt="茶频道LOGO展示" width="50" height="15" border="0" align="absmiddle"></a> Add:西安欧亚学院二胡工作室 Phone:02988286078 Postcode:710065 div></td>
</tr>
</table>
</body>
</html>

<!-- 用户名验证以及数据库写入 -->
<!--#include file="conn.asp"-->
<% on error resume next %>
<%
dim username,password,password2,sex,age,qq,email,phone,address,education,question,answer,ip,rs,conn
username=cstr(trim(request.form("name")))
password=cint(trim(request.form("password")))
password2=cint(trim(request.form("password2")))
if password<>password2 then
response.write "<script language=javascript>"
response.write "alert('验证提示:请检查密码和确认密码是否一致!');"
response.write "document.location='index.htm';"
response.write "</script>"
end if
sex=cint(trim(request.form("sex")))
age=cint(trim(request.form("age")))
qq=cint(trim(request.form("qq")))
email=cstr(trim(request.form("email")))
phone=cstr(trim(request.form("phone")))
address=cstr(trim(request.form("address")))
education=cstr(trim(request.form("education")))
if education="o" then
education="小学"
elseif education="1" then
education="中学"
elseif education="2" then
education="中专"
elseif education="3" then
education="大学专科"
elseif education="4" then
education="大学本科"
elseif education="5" then
education="硕士研究生"
elseif education="6" then
education="博士生"
else
education="其他"
end if
question=cstr(trim(request.form("question")))
answer=cstr(trim(request.form("answer")))
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip = "" Then
ip=Request.ServerVariables("REMOTE_ADDR")
end if

set rs=server.createobject("adodb.recordset")
sql="select * from guest where name='"&username&"'"
rs.open sql,conn,1,1
if rs.recordcount >0 then
response.write "<script language=javascript>"
response.write "alert('验证提示:此用户名已存在!');"
response.write "document.location='index.htm';"
response.write "</script>"
else
if rs.eof=true then
rs.movelast
end if
rs.addnew
rs("name")=username
rs("password")=password
rs("sex")=sex
rs("age")=age
rs("qq")=qq
rs("email")=email
rs("phone")=phone
rs("address")=address
rs("education")=education
rs("question")=question
rs("answer")=answer
rs.update
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<script language="javascript" >
alert("填加数据库成功,恭喜您成为茶频道的成员!")
document.location="select.htm"
</script>

搜索更多相关主题的帖子: 数据库 ASP 
2005-12-16 17:29
快速回复:[求助]请高手帮忙,我的ASP向数据库写不入数据???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017782 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved