<!--#include file="../Inc.asp"-->
<!--#include file="../ydzq.asp"-->

<%call head()
dim nam,roomadmin,txt,TP,ID
nam=usb(request("nam"))
TP=usb(request("TP"))
ID=usb(request("id"))
roomadmin=request("roomadmin")

set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from Chat order by id desc",conn,1,1
If Not rs.eof Then

if Instr(","&rs("roomadmin")&",",","&myid&",") > 0 then
if saytk<>1 then
  Call Error("<title>出错</title></head><body><body bgcolor="""&yanse12&"""><p>一个会员只可以建立一个聊天室！")
else
  Call Error("<card id=""main"" title=""出错"" ><p>一个会员只可以建立一个聊天室！")
end if
end if
end if
rs.close
set rs=nothing


if roomadmin="0" then
if saytk<>1 then
  Call Error("<title>出错</title></head><body><body bgcolor="""&yanse12&"""><p>密码不能为0！")
else
  Call Error("<card id=""main"" title=""出错"" ><p>密码不能为0！")
end if
end if
txt=usb(request("txt"))

IF TP<>"" then

if ID="" or IsNumeric(ID) = False then
if saytk<>1 then
  Call Error("<title>出错</title></head><body><body bgcolor="""&yanse12&"""><p>ID无效！")
else
  Call Error("<card id=""main"" title=""出错"" ><p>ID无效！")
end if
end If

End if
Call saycarda("编辑聊天室")



if nam="" then
  Call Error("名称不能为空！")
end if

set rs=Server.CreateObject("ADODB.Recordset")
IF TP<>"" then
rs.open"select * from chat where ID="&ID,conn,1,2
else
rs.open"select * from chat",conn,1,2
rs.addnew
end if
rs("roomname")=nam
rs("suxin")=1
if roomadmin<>"" then 
rs("roomadmin2")=roomadmin

end if

rs("roomadmin")=myid
IF TP="" then
rs("mmtext")=myid
else

end if
if txt<>"" then rs("title")=txt

rs.update
rs.close
set rs=nothing

'取ID
dim chatids
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select top 1 ID from [chat] order by id desc",conn,1,1
chatids=rs("ID")
rs.close
set rs=nothing
 conn.execute("update Users Set ChatID = "&chatids&" where ID="&myid)
conn.execute("update Chat Set Chatnum =1 where ID="&chatids)

conn.close
set conn=Nothing

IF TP<>"" Then
response.write"成功编辑自建聊天室!<br/>"
Else
response.write"成功增加自建聊天室<br/>"
end If

response.write"----------<br/>"
response.write"<a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">聊吧大厅</a>"
%><!--#include file="../fanhui.asp"-->
<%call headsay()%>