File size: 802B
<?php
include 'inc/db.php';
include 'inc/1.php';
if (!$user || !isset($_GET['id']))
{
header('Location: /aut.php');
exit();
}
$q=mysql_query("SELECT `id` FROM `user` WHERE `id` = '".intval($_GET['id'])."'");
if (mysql_num_rows($q)==0)
{
header('Location: /index.php');
exit();
}
$q=mysql_query("SELECT `id` FROM `friends` WHERE (`user1` = '$user[id]' AND `user2` = '".intval($_GET['id'])."') OR (`user2` = '$user[id]' AND `user1` = '".intval($_GET['id'])."')");
if (mysql_num_rows($q)>0)
{
header('Location: /index.php');
exit();
}
mysql_query("INSERT INTO `friends` (`timesend`, `user1`, `user2`, `who`) values ('".time()."', '$user[id]', '".intval($_GET['id'])."', '$user[id]')");
echo '<div class="msg">
Заявка отправлена!
</div>';
include 'inc/foot.php';
?>