<!--#include file="inc/conn.asp"-->
<!--#include file="inc/safe.asp"-->
<!--#include file="inc/config.asp"-->
<!--#include file="inc/const.asp"-->
<%
if MemberName="" then
  response.Redirect("userlogin.asp")
  response.end
end if
%>
<%
if request.QueryString("action")="save" then
  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 "<script language='javascript'>alert('没有找到您要添加的好友，点击返回'！);history.back(-1)</script>"
  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 "<script language='javascript'>alert('此用户已经为您的好友!');history.back(-1)</script>"
  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 "<script language='javascript'>alert('好友已经成功添加！');window.location='"& rurl &"';</script>"
response.end
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>红嫂视屏交友网</title>
<meta name="keywords" content="情感,在线,新新,照片,动感影片,诗歌,爱情,纯洁,心连心">
<meta name="description" content="红嫂视屏交友情缘 情感在线">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
	background-image: url();
}
.STYLE8 {
	color: #CC0099;
	font-size: 12px;
	font-weight: bold;
}
.STYLE31 {color: #666666; font-size: 12px;}
-->
</style>
<script Language="JavaScript">
<!--
function CheckAll()  
{  
	if (form.fname.value.length==0)
	{alert("请填写好友帐号！");
	form.fname.focus();
	return false;   
	}	
	return true;  
}  
-->
</script>
</head>
<body>
<table width="1002" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!--#include file="top.asp"--></td>
  </tr>
</table>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="204" height="328" valign="top"><!--#include file="memberleft.asp"-->
&nbsp;</td>
    <td width="583" valign="top"><table width="565" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td><TABLE width="100%" border=0 
            cellPadding=0 cellSpacing=0 bgColor=white class="STYLE4" >
              <TBODY>
                <TR>
                  <TD width="2%" align=left background="image/tiao_4.gif"><img src="image/tiao_3.gif" width="10" height="31"></TD>
                  <TD height="31" align=center background="image/tiao_4.gif"><TABLE width=530 height="27" border=0 cellPadding=0 cellSpacing=0>
                      <TBODY>
                        <TR>
                          <TD height="27" align=middle class="pgd"><font class="pgd">添加好友</font></TD>
                        </TR>
                      </TBODY>
                  </TABLE></TD>
                  <TD width="2%" align="right" background="image/tiao_4.gif"><img src="image/tiao_2.gif" width="10" height="31"></TD>
                </TR>
              </TBODY>
          </TABLE></td>
        </tr>
        <tr>
          <td height="299" valign="top" style="border-left:#C7C8CC 1px solid;border-right:#C7C8CC 1px solid;border-bottom:#C7C8CC 1px solid"><br>
            <table width="520" border="0" align="center" cellpadding="0" cellspacing="1">
              <tr>
                <td valign="top" align="center"><table width="405" height="104" border="0" cellspacing="0" class="STYLE4">
                    <form name="form" action="addfriend.asp?action=save" method="post" onSubmit="return(CheckAll());">
                      <tr>
                        <td height="14">&nbsp;</td>
                      </tr>
                      <tr>
                        <td height="90"><table height="45" border="0" cellpadding="3" cellspacing="0" class="STYLE4">
                            <tr>
                              <td height="25" width="119">要添加好友帐号：</td>
                              <td height="25" width="244"><input name="fname" type="text" class="put" id="fname" size="20" maxlength="50">
                              </td>
                            </tr>
                            <tr align="center">
                              <td height="30" colspan="2" valign="middle"><input type="submit" value="　提交　" name="B1" class="put1"></td>
                            </tr>
                        </table></td>
                      </tr>
                    </form>
                </table></td>
              </tr>
              <tr>
                <td height="1" background="images/hline.gif"></td>
              </tr>
            </table>
          </td>
        </tr>
    </table></td>
    <td width="163" valign="top"><!--#include file="fenlei.asp"--></td>
  </tr>
</table>
<table width="1002" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!--#include file="root.asp"--></td>
  </tr>
</table>
</body>
</html>
