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

<%call head()
Call saycarda("推荐有奖")
dim clickid,Action,TP
  Action = Request("Action")
if Action="ok" then
  clickid=Trim(Request.form("clickid"))
  IF Request.QueryString("TP")="save" Then
if clickid = "" or IsNumeric(clickid) = False then
call error("推荐人ID出错！")
end if
if abs(clickid) = myid then
call error("推荐人不能是自己！")
end if 
'检查ID是否存在
dim regclick
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT id FROM users where id="&clickid,conn,1,1
if rs.eof then
  rs.close
  set rs=Nothing
call error("推荐人ID不存在！")
end if 

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT upsize FROM users where id="&myid,conn,1,1
if rs("upsize")="1" then
  rs.close
  set rs=Nothing
call error("重复推荐或者您已经选择不推荐！")
end if  
  rs.close
  set rs=Nothing
'得到100币
  conn.execute("update Users Set myjb = myjb + "&abs(clickjb)&",huashu=huashu+2 where ID="&clickid)
 
  conn.execute("update Users Set myjb = myjb + "&abs(regjb)&",mytl = mytl + "&abs(regtl)&",myml = myml + "&abs(regml)&",myjy = myjy + "&abs(regjy)&",upsize = 1 where ID="&myid)

'==========系统消息==============
dim msgx
msgx = "恭喜！您成功介绍新会员ID" &myid
msgx = msgx & "加入"&waptitle&"！"
msgx = msgx & "\\您已获得官方奖励"&abs(clickjb)&getcent&"，2朵鲜花,感谢您对"&waptitle&"的支持！"
set rs=Server.CreateObject("ADODB.Recordset")
rs.open"select * from guest",conn,1,2
rs.addnew
rs("fnr")=msgx
rs("sid")=clickid
rs("fid")=0
rs.update
rs.close
set rs=nothing
'==========系统消息==============

conn.close
set conn=nothing

  Response.write "操作成功，您的推荐人已得到"&abs(clickjb)&getcent&"和2朵鲜花,您也得到"&abs(regjb)&getcent&","&abs(regtl)&"体力,"&abs(regml)&"魅力,"&abs(regjy)&"经验的奖励！<br/>"
  Response.write "欢迎您加入"&waptitle&"！"
  response.write "<br/><a href=""show.asp?sid="&sid&"&amp;saytk="&saytk&""">我的小屋</a>"

Else
If saytk>1 then
%>
<form name="form" method="post" action="clickid.asp?TP=save&amp;sid=<%=sid%>&amp;saytk=<%=saytk%>">
<%
End if
 Response.Write "输入推荐人ID："
 Response.Write "<br/><input emptyok=""false"" value=""0"" name=""clickid"" format=""*N""/>"
If saytk>1 Then
response.write "<input type=""submit"" name=""Submit"" value=""确定修改""></form><br/>"
else

 Response.Write "<br/><anchor>确定<go href=""clickid.asp?TP=save&amp;saytk="&saytk&"&amp;sid="&sid&""" method=""post"">"
 Response.Write "<postfield name=""clickid"" value=""$(clickid)""/>"
 Response.Write "<postfield name=""Action"" value=""ok""/>"
 Response.Write "</go></anchor>"
 end If
 End if
 else
 Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT upsize FROM users where id="&myid,conn,1,1
if rs("upsize")="1" then
  rs.close
  set rs=Nothing
call error("重复推荐或者您已经选择不推荐！")
end if  
  rs.close
  set rs=Nothing
 conn.execute("update Users Set myjb = myjb + "&abs(regjb)&",mytl = mytl + "&abs(regtl)&",myml = myml + "&abs(regml)&",myjy = myjy + "&abs(regjy)&",upsize = 1 where ID="&myid)
 
   Response.write "操作成功，您得到"&abs(regjb)&getcent&","&abs(regtl)&"体力,"&abs(regml)&"魅力,"&abs(regjy)&"经验的奖励！<br/>"
  Response.write "欢迎您加入"&waptitle&"！"
 end if
%>
<!--#include file="fanhui.asp"-->
<%
Call headsay()
%>