提交表单的程序错在哪儿了?

yiyun59 2012-09-12 11:53:54
页面表单的程序index.asp
-------------------
<FORM name=testform action="sendmail_wsdg.asp" method=post>
<tbody>
<tr>
<td height=471 bgcolor="#FFFFCC"><font color=#ff0000> 
</font>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=28><div align="center">在线订购</div></td>
</tr>
</table>
<table width="92%" height="32" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="left"><font color=#ff0000> *</font>姓  名:
<input name=a1 class="4" size=16>
</div></td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=38><div align="left"><font color=#ff0000> </font> 性  别:
<select name=a2 class="4" size=1>
<option value=男 selected><font face="宋体">男</font></option>
<option value=女><font face="宋体">女</font></option>
</select>
</div></td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=38><div align="left"><font color=#ff0000></font><font
color=#ff3333> *</font>座  机:
<input name=a3 class="4" size=13>
手  机:
<input name=a4 class="4" size=22>
</div></td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=38><div align="left"><font color=#ff0000> </font><font
color=#ff3333>*</font>送货地址及邮编:
<input name=a5 class="4" size=38>
</div></td>
</tr>
</table>

<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=38><div align="left"><font color=#ff0000> </font><font
color=#ff3333>*</font>产品选择:
<select name=a6 size=1 class="4" style="width:90" select>
<option value=" 000">000</option>
<option value="111">111</option>
<option value="222">222</option>
</select>
</div></td>
</tr>
</table>

<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=38><div align="left"><font color=#ff0000> </font><font
color=#ff3333>*</font>付款方式:
<input type="radio" checked name="a7">
货到付款   <input type="radio">款到发货

</div></td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=63 align="center" valign="middle">
<div align="left" vlign="center"> 备注提醒:
<textarea cols="50" rows="3" name="a8"></textarea>
</div>
</td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height=36 valign="middle"><div align="left"><font color=#ff0000> </font>
<input name=B1 type=submit class="4" value="发 送">
  
<input name=B2 type=reset class="4" value="清 除">
</div></td>
</tr>
</table>
</td>
</tr>
</tbody>
</form>





连接数据库的程序connection_wsdg.asp
-------------------
<%

dim conn
dim connstr
connstr="DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("data/wsdg.mdb")
set conn=Server.Createobject("Adodb.Connection")
conn.CommandTimeout =30
conn.ConnectionTimeout =30
conn.open connstr
%>

接收数据的程序sendmail_wsdg.asp
-------------------
<!--#include file="connection_wsdg.asp"-->
<%
Function SqlStr(varTemp)
varTemp=Replace(varTemp,"<","<")
varTemp=Replace(varTemp,">",">")
sqlstr=vartemp
End Function
dim a1,a2,a3,a4,a5,a6,a7,a8,wtime
a1=sqlstr(request("a1"))
a2=sqlstr(request("a2"))
a3=sqlstr(request("a3"))
a4=sqlstr(request("a4"))
a5=sqlstr(request("a5"))
a6=sqlstr(request("a6"))
a7=sqlstr(request("a7"))
a8=sqlstr(request("a8"))
set rs=server.createobject("adodb.recordset")
sql="select * from consumer"
rs.open sql,conn,3,3
rs.addnew
rs("a1")=a1
rs("a2")=a2
rs("a3")=a3
rs("a4")=a4
rs("a5")=a5
rs("a6")=a6
rs("a7")=a7
rs("a8")=a8
rs("wtime")=date()
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

access数据库wsdg.mdb,建立一个表格consumer
字段名称  数据类型
a1 文本
a2 文本
a3 文本
a4 文本
a5 文本
a6 文本
a7 文本
a8     备注
wtime   日期/时间
...全文
84 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2012-09-13
  • 打赏
  • 举报
回复
这个有些难找。一行一行删除排除吧。或加上on error resume next
yiyun59 2012-09-13
  • 打赏
  • 举报
回复
点击页面“发送”时,出现“500内部服务器错误”。不知道是哪里出错了,请各位大侠帮忙,谢谢
yiyun59 2012-09-13
  • 打赏
  • 举报
回复
OL,谢谢各位!
suano 2012-09-13
  • 打赏
  • 举报
回复
那是你的JS验证没有检测到,导致你在不允许为空的位置存入空值,检测下你的JS,或者在数据为空时设置一个默认值。
yiyun59 2012-09-13
  • 打赏
  • 举报
回复
谢谢各位,我重新建立了一个 access数据库,就可以提交了!

现在还有一个问题:姓名、电话、送货地址这几项,我想做成提交时不能为空。

我先在页面用javascript控制,然后数据库需要将字段设为“必填”吗?我设为“必填”就会出现500内部错误,默认就可以了,但提交为空时不会提示信息?
Rotel-刘志东 2012-09-13
  • 打赏
  • 举报
回复
分步骤调试一下。print
Rotel-刘志东 2012-09-13
  • 打赏
  • 举报
回复
程序上看是没有任何问题的。是不是浏览器的问题。
yiyun59 2012-09-13
  • 打赏
  • 举报
回复
谢谢dogfish,我建的access数据库有什么问题吗?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧