------From表单
<form action="index.asp?action=SubmitData" method="post" name="theForm" onsubmit="return SubChk()" style="width: 306px; height: 136px">
<table>
<tbody>
<tr>
<td>姓名:</td>
<td><input type="text" id="txtName" name="txtName" size="25" /></td>
</tr>
<tr>
<td>手机号码:</td>
<td><input type="text" id="txtPhone" name="txtPhone" size="25" /></td>
</tr>
<tr>
<td>Q Q:</td>
<td><input type="text" id="txtqq" name="txtqq" size="25" /></td>
</tr>
<tr>
<td>留言内容:</td>
<td><textarea id="txtContent" name="txtContent"></textarea></td>
</tr>
<tr>
<td>
<input type="submit" name="submit" value=" 提交 ">
</td>
</tr>
</tbody>
</table>
</form>
'---------条件判断验证
<script language="javascript">
function SubChk() {
if (document.theForm.txtName.value == "") {
alert ("必须输入您的姓名!");
return false;}
if (document.theForm.txtPhone.value == "") {
alert ("必须输入您的电话号码!");
return false;}
if (document.theForm.txtContent.value == "") {
alert("必须输入您的留言内容!");
return false;}
return true;
}
</script>
'-------留言添加到表中
<%
dim action
action=request.QueryString("action")
if action="SubmitData" then
'--------数据库路径------------------------
set Conn=server.createobject("adodb.connection")
Conn.open"provider=microsoft.jet.oledb.4.0;data source=" & server.mappath("db/#cswork#.mdb")
'--------添加留言---------------------------
Set rsmes=Server.Createobject("Adodb.Recordset")
sql="select * from bdmessage"
rsmes.open sql,conn,1,3
rsmes.addnew
rsmes("mx_title")=""
rsmes("mx_name")=request("txtName")
rsmes("mx_tel")=request("txtPhone")
rsmes("mx_email")=""
rsmes("mx_qq")=request("txtqq")
rsmes("mx_note")=request("txtContent")
rsmes("mx_time")=now()
rsmes("mx_open")="1"
rsmes("mx_hf")=""
rsmes.update
rsmes.close
set rsmes=nothing
'----------------------------------
response.Write "<script language=javascript>alert('提交成功!');history.go(-1);</script>"
end if%>