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

if($_POST['name'] != '')
{
$cname =addslashes($_POST['name']);
$loc =addslashes($_POST['loc']);
$add =addslashes($_POST['add']);
$conta = $_POST['con'];
$em =addslashes($_POST['em']);
$mi = addslashes($_POST['mi']);
$vi = addslashes($_POST['vi']);

//$tax='';
$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 companydata");
$num=mysqli_fetch_array($sql);
if($num>0)
{
$sql=mysqli_query($con,"UPDATE companydata set School='$cname',Location='$loc',Addres='$add',Mission='$mi',Contact='$conta',Vision='$vi',Email='$em',Lastupdate='$timenow'");
if($sql)
{
//$msgg='updated company profile details';
//$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
{
$sql4=mysqli_query($con,"INSERT INTO companydata(School,Contact,Email,Location,Addres,Mission,Vision) VALUES ('$cname','$conta','$em','$loc','$add','$mi','$vi')");
if($sql4)
{
//$msgg='added company profile details';
//$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 submit data";	
}	
}

//echo $insert?'ok':'err';
} 
?>