<?php
include('../include/config.php');
///error_reporting(0);
session_start();
$iduser=$_SESSION['user_idd'];
  
 if(isset($_POST['cto'])) 
 {
$cto =addslashes($_POST['cto']);    
$cfro =addslashes($_POST['cfro']);

$date = new DateTime("now", new DateTimeZone('Africa/Nairobi') );
$timenow=$date->format('Y-m-d H:i:s');
$timenow2=$date->format('Y-m-d');
$month=$date->format('M');

$sql=mysqli_query($con,"SELECT * FROM pupils where Claz='$cto'");
$num=mysqli_fetch_array($sql);
if($num>0)
{
  echo $cto." class already exist, You can't combine two classes !!"; 
}else
{
    
$sql=mysqli_query($con,"UPDATE pupils SET Claz='$cto' where Claz='$cfro'");
if($sql)
 {
 $msgg='moved '.$cfro.' to '.$cto;
 $sql3=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month)values('$iduser','$msgg','$timenow','$timenow2','update','$month')");
if($sql3)
{ }
echo "success";
//}else
//{
//echo "Unable to update data";	
}	
}
 }
 
 else
  {  
 echo 'Nothing Received';
}
//echo $insert?'ok':'err';

?>