<?php include("header.php");
if(!isset($_SESSION['cid']))
{
	?>
		<script>
        	window.location="<?php echo $actual_link?>index";
        </script>
	<?php
}
if(isset($_POST['submit']))
{
	$closeAC=$_POST['closeAC'];
	
	if($closeAC=="Yes")
	{
		
		$sqlallad=mysql_query("select * from tbl_ads posted_userid='".$_SESSION['cid']."'");
		while($resallad=mysql_fetch_assoc($sqlallad))
		{
			$ads=$resallad['ads_id'];
			mysql_query("delete from tbl_queries where for_adid='".$ads."'");
			
			mysql_query("delete from tbl_ads where ads_id='".$ads."'");
			
			mysql_query("delete from tbl_favorite where ads_id='".$ads."'");
			
			
			mysql_query("delete from tbl_notification where ads_id='".$ads."'");
			
			mysql_query("delete from tbl_chats where ads_id='".$ads."'");
			
			
		}
		$delete=mysql_query("delete from tbl_users where userid='".$_SESSION['cid']."'");
		
		mysql_query("delete from tbl_favorite where userid='".$_SESSION['cid']."'");
		mysql_query("delete from tbl_notification where user_id='".$_SESSION['cid']."'");
		mysql_query("delete from tbl_queries where querybyid='".$_SESSION['cid']."'");
		
		mysql_query("delete from tbl_chats where sender_id='".$_SESSION['cid']."' or receiver_id='".$_SESSION['cid']."'");
		
		
		
		?>
		<script>
        	window.location="signout";
        </script>
		<?php
	}
	else
	{
		?>
		<script>
        	window.location="account_home";
        </script>
		<?php
	}
}
?>
 
<div class="main-container">
<div class="container">
<div class="row">

<?php include("profileside.php");?>

<div class="col-sm-9 page-content">
<form  method="post"> 
<div class="inner-box">
<h2 class="title-2"><i class="icon-cancel-circled "></i> Close account </h2>
<p>You are sure you want to close your account?</p>
<div>

<label class="radio-inline">
<input type="radio" name="closeAC" id="inlineRadio1" value="Yes"> Yes
</label>
<label class="radio-inline">
<input type="radio" name="closeAC" id="inlineRadio2" value="No"> No
</label></div>
<br>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>

</div> 
</form>
</div>
 
</div>
 
</div>
 
</div>
 
<?php include("footer.php");?>
