<?php
session_start();
include 'dbc.php';

date_default_timezone_set("Asia/Karachi");
$today=date("Y-m-d");
$month = date("m",strtotime($today));
		$year = date("Y",strtotime($today));
		 $month_name = date("F", mktime(0, 0, 0, $month, 10));
		 $my=$month_name . " " . $year;
$userid=$_SESSION["userid"];
$username=$_POST["username"];
if($_POST['delete']) // from button name="delete"
	{
		$checkbox = $_POST['checkbox']; //from name="checkbox[]"
		$countCheck = count($_POST['checkbox']);
		
		for($i=0;$i<$countCheck;$i++)
		{
			$del_id  = $checkbox[$i];
			
			$userid=$_SESSION["userid"];
			$today=date("Y-m-d");
			$sql = "SELECT * FROM addarea where id = '$del_id' and user_id='$userid'";
$result=$conn->query($sql);
$row = $result->fetch_assoc();
$areaname=$row['cname'] ;
			
			$sql1 = "Insert into userarea (id,date,username,areaname,user_id) values (null,'$today','$username','$areaname','$userid')";
$conn->query($sql1);


		
	
	
	
			
		}
			if($result)
		{	
				header('Location: Alot_Area.php');
			}
			else
			{
				header('Location: Alot_Area.php');
			}
	}
  
	
	

// do the update and print out some info just to provide some visual feedback





?>
