<?php


include("../include/config.php");
include_once("../include/functions/import.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Administrator Successfully Created";
	Stemplate::assign('message',$message);
}
        
if($_REQUEST['add_admin'])
{
	$username = escape($_REQUEST[username]);
	$email = escape($_REQUEST[email]);
	$password = escape($_REQUEST[password]);
	
	if ($username == "")
	{
		$error = "Error: Username cannot be empty.";
	}
	elseif ($email == "")
	{
		$error = "Error: E-mail cannot be empty.";
	}
	elseif ($password == "")
	{
		$error = "Error: Password cannot be empty.";
	}
	
	if ($error == "")
	{
		$password = md5($password);
		$sql = "insert administrators set
		username = '".mysql_real_escape_string($username)."',
		password = '".mysql_real_escape_string($password)."',
		email = '".mysql_real_escape_string($email)."'";
		$conn->execute($sql);
		header("Location: createadmin.php?update=success");
	}
}
Stemplate::assign('error',$error);
STemplate::display("administrator/show_message.tpl");
STemplate::display("administrator/createadmin.tpl");
?>