<?php

require_once 'core/system.php';








head('Брак');



reg();


if(isset($_GET['yes']) and !empty($_GET['id'])){
    $id = int($_GET['id']); 

 $easy  = $dbc->query("select * from `brak` where `id` = '".$id."'")->fetch_assoc(); 


 $man  = $dbc->query(" select * from `users` where `id` = '".$easy['man']."'")->fetch_assoc();    

   

if($user['brak']>0){ header('location:index.php');exit;}

if($man['brak']>0){ header('location:index.php');exit;}

if($user['brak']>0){ header('location:index.php');exit;}

if($easy['active']==2){ header('location:index.php');exit;}

    $dbc->query("UPDATE `users` SET `brak`='".$easy['women']."' WHERE `id`='".$easy['man']."'");

$dbc->query("UPDATE `users` SET `brak`='".$easy['man']."' WHERE `id`='".$easy['women']."'");



$dbc->query("UPDATE `brak` SET `active`=2 WHERE `id`='".id."'"); 

 

header('location: my.php');exit;}





if(isset($_GET['razvod'])){

    $id = int($_GET['id']); 


if($user['sex']==1){
 $easy  = $dbc->query("select * from `brak` where `women` = '".$user['brak']."'")->fetch_assoc(); 



}

 if($user['sex']==2){

$easy  = $dbc->query("select * from `brak` where `man` = '".$user['brak']."'")->fetch_assoc(); }


if(!$easy){ header('location:index.php');exit;}



if($user['brak']==0){ header('location:index.php');exit;}




if($user['sex']==1){



if($user['id']!=$easy['man']){
 header('location:index.php');exit;}



}

if($user['sex']==2){



if($user['id']!=$easy['women']){

 header('location:chat.php');exit;}




}




$dbc->query("UPDATE `users` SET `brak`=0 WHERE `id`='".$easy['man']."'");

$dbc->query("UPDATE `users` SET `brak`=0 WHERE `id`='".$easy['women']."'");




$dbc->query("delete from `brak` where `id`  = '".$easy['id']."'");

 

header('location: my.php');exit;}










foot();




 

