<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<!-- #include file="inc/wenda_reset.asp" -->
<!-- #include file="session.asp" -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>发表问答</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="refresh" content="1;URL=<%=request.ServerVariables("HTTP_REFERER")%>">
</head>
<body>
<%
dim CatalogId,Title,Content,UserName,ctitle
if  Cstr(request.Form("vertcode")) <> Cstr(Session("GetCode"))  then 
	response.Write("<script>alert(""验证码错误！请返回刷新页面后再试。"");history.back();</script>")
	Response.End
end if
Title=tohtml(request.Form("Title"))
Content=tohtml(request.Form("Content"))

if(request.Form("CatalogId")<>"") then
	CatalogId=Clng(request.Form("CatalogId"))
else
	CatalogId=0
end if
if(CatalogId=0) then
	response.Write("<script>alert(""请选择分类。"");history.back();</script>")
	Response.End
end if
if(len(Title)<1 or len(Content)<1) then
	response.Write("<script>alert(""以下内容不能为空：标题、内容"");history.back();</script>")
	Response.End
end if
userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if userip = "" then 
userip = Request.ServerVariables("REMOTE_ADDR")
end if
if(CatalogId>0) then
	set rs=conn.execute("select Title from t_wenda_catalog where id="&CatalogId)
	if not rs.eof then
		ctitle=rs(0)
	end if
	rs.close
	set rs=nothing
end if
set rs=server.CreateObject("adodb.recordset") 
rs.open "select * from t_wenda where 1=0 order by id desc",conn,3,3
rs.addnew
rs("CatalogId")=CatalogId
rs("UserId")=checkusername
rs("Title")=Title
rs("Content")=Content
rs("Status")=0
rs("PubIp")=userip
rs("PubDate")=now()
rs("IsRem")=0
rs("IsHot")=0
rs("Hits")=1
rs("IsCheck")=1
rs("LastReply")=""
rs("CatalogTitle")=ctitle
rs.update
rs.close
set rs=nothing
dim lastid
set rs=conn.execute("select top 1 id from t_wenda order by id desc")
if not rs.eof then
	lastid=rs(0)
else
	lastid=1
end if
rs.close
set rs=nothing
'call SetShowHtm(lastid)
Session("GetCode")=""

%>成功发表问答，正在转入，请稍候.................
</body>
</html>
<%
call connclose
%>
</body>
</html>
