<?php
if(isset($_SESSION['user']))
{
	$user=$_SESSION['user'];
}
else
{
	header("Location: ../views/signinPage.php?message=".urlencode("Login Again!"));
	exit();
}
$aerror = "";
if(isset($_POST['addGroup']))
{
	$name = $_POST['name'];
	
	include_once('../models/group.php');
	$groupId = group::insertGroup($name);
	if($groupId)
	{
		if(group::insertMember($groupId, $user['username']))
		{
			$aerror = "Group Created!";
			header("Location: ../views/allgroups.php");
		}
	}
	else
	{
		$aerror = "Cannot Create a new Group!";
	}
}

?> 