下面是完整代码:
<!--#include file="conn.asp"-->
<html>
<head>
<title>用户评论</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="3" topmargin="4" marginwidth="00">
<%dim id,action
id=request.QueryString("id")
action=request.QueryString("action")
if action="save" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_pinglun",conn,1,3
rs.addnew
rs("id")=id
rs("pinglunname")=HTMLEncode2(trim(request("pinglunname")))
rs("pingluncontent")=HTMLEncode2(trim(request("pingluncontent")))
rs("pinglundate")=now()
rs.update
rs.close
set rs=nothing
response.write "<br><br><table width=96% border=0 align=center cellpadding=0 cellspacing=0><tr><td height=86 bgcolor=#F5F5F5><div align=center>"
response.write "您的评论已成功提交!!<br><br><a href=javascript:window.close()>关闭窗口</a></div></td></tr></table>"
response.End
end if
%>
<table width="96%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td bgcolor="#0066CC"> </td>
</tr>
<tr><form name="pinglunform" method="post" action="pinglun.asp?action=save&id=<%=id%>">
<td bgcolor="#F5F5F5">
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
<tr bgcolor="#F5F5F5">
<td width="23%">您的姓名:</td>
<td width="77%"><input name="pinglunname" type="text" id="pinglunname" size="12"></td>
</tr>
<tr bgcolor="#F5F5F5">
<td valign="top">评论正文:</td>
<td><textarea name="pingluncontent" cols="26" rows="5" id="pingluncontent"></textarea></td>
</tr>
<tr bgcolor="#F5F5F5">
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="提 交" onClick="return check();">
<input type="reset" name="Submit2" value="清 除">
</div></td>
</tr>
</table>
</td></form>
</tr>
</table>
</body>
</html>
<%function HTMLEncode2(fString)
fString = Replace(fString, CHR(13), "")
fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
fString = Replace(fString, CHR(10), "<BR>")
HTMLEncode2 = fString
end function%>
<script LANGUAGE="javascript">
<!--
function checkspace(checkstr) {
var str = '';
for(i = 0; i < checkstr.length; i++) {
str = str + ' ';
}
return (str == checkstr);
}
function check()
{
if(checkspace(document.pinglunform.pinglunname.value)) {
document.pinglunform.pinglunname.focus();
alert("请填写您的姓名!");
return false;
}
if(checkspace(document.pinglunform.pingluncontent.value)) {
document.pinglunform.pingluncontent.focus();
alert("请填写评论正文!");
return false;
}
}
//-->
</script>