<?php 
session_start();
//mysql_connect("localhost","root","vertrigo") or die("Error Connecting Server");
//mysql_select_db("sm") or die("Error Opening Database");
include 'dbc.php';


$today=date("Y-m-d");

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");
			$sqlp14 = "select * from qu where id='$del_id' and user_id='$userid'";
 							$finishstock=mysql_query($sqlp14) or die("Error : " . mysql_error());
   							$app1=mysql_fetch_array($finishstock);
   							$class_name=$app1["class_name"];
							$sub_name=$app1["sub_name"];
							$p_type=$app1["p_type"];
							$question=$app1["question"];
							$optionn=$app1["optionn"];
			
			$sql2 = "Insert into add_paper (id,date,class_name,sub_name,p_type,question,optionn,user_id)values (null,'$today','$class_name','$sub_name','$p_type','$question','$optionn','$userid')";

			
			$result=mysql_query($sql2) or die ("Error:" . mysql_error());
			
		}
			if($result)
		{	
				header('Location: enter_question_paper_report.php');
			}
			else
			{
				echo "Record dos not add";
			}
	}
?>
