<?php
include('../include/config.php');
//error_reporting(0);
session_start();
$iduser= $_SESSION['user_idd'];

$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');

if(isset($_POST['opt']))
 {
 $opt=addslashes($_POST['opt']);
 $cla=addslashes($_POST["cla"]);
 
 if($opt=='activeme')
 {
 $sql=mysqli_query($con,"UPDATE pupils set Status='Active' WHERE Claz='$cla'");
 if($sql)
 {
 $msgg='activated '.$cla.' data.';
 $sql3=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month)values('$iduser','$msgg','$timenow','$timenow2','update','$month')");    
     
echo 'updated';
}else
 {
 echo 'unable to update data';
 } 
 }else
 {
 
 $sql=mysqli_query($con,"UPDATE pupils set Status='Inactive' WHERE Claz='$cla'");
 if($sql)
 {
 $msgg='freezed '.$cla.' data.';
 $sql3=mysqli_query($con,"INSERT INTO activity(user,Action,Tim,Dat,shortmsg,Month)values('$iduser','$msgg','$timenow','$timenow2','update','$month')");    
     
echo 'updated';
}else
 {
 echo 'unable to update data';
 }    
 }
 }
 ?>