<!--#include file="inc/conn.asp"-->
<!--#include file="inc/safe.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/const.asp"-->
<link href="style.css" rel="stylesheet" type="text/css">
<%
if MemberName="" then%>
 <p align="center" class="STYLE30"><br><br> 对不起！游客无法留言。如果你还是不是本站会员，请您<a href="newsreg.asp" target="_blank">注册</a>后登陆本站进行此操作。如果您已经是本站会员，请<a href="userlogin.asp" target="_blank">登陆</a>。<br> <br> </p>
<%  response.end
end if
%>
<%
  dim errmsg
  errmsg=""

dim fname,fid,rurl

rurl=request.ServerVariables("HTTP_REFERER")
fname=trim(ReplaceBadChar(request("fname")))
fid=trim(ReplaceBadChar(request.QueryString("fid")))

set rst=server.CreateObject("adodb.recordset")
if fname<>"" then
  sql1="select userid,username from user_info where username='"& fname &"'"
end if  
if fid<>"" then
  sql1="select userid,username from user_info where userid="& fid &""
end if
rst.open sql1,conn,1
if rst.eof and rst.bof then
  response.Write "<div align='center' style='font-size:14px'><br>没有找到您要添加的好友，请<a href='javascript:history.back(-1)'>返回</a>继续！</div>"
  response.end
end if
fname=rst("username")
fid=rst("userid")
rst.close
set rst=nothing

'on error resume next
set rs=server.CreateObject("adodb.recordset")
sql="select * from sd_friend where friendid="& fid &" and userid="&userid&""
rs.open sql,conn,1,3
if not (rs.eof or rs.bof) then
  response.Write "<div align='center' style='font-size:14px'><p><br>此用户已经为您的好友。<br><a href='javascript:history.back(-1)'>返回</a>&nbsp;&nbsp;</p></div>"
  response.end
end if 
rs.addnew
rs("userid")=userid
rs("friendname")=fname
rs("friendid")=fid
rs("addtime")=now()
rs.update
rs.close
set rs=nothing

conn.close
set conn=nothing

response.Write "<div align='center' style='font-size:14px'><p><br>此用户已经添加为您的好友。<br><a href='userzq.asp?user_id="&fid&"'>确定</a>&nbsp;&nbsp;</p></div>"
  response.end
%>