<?php


include("../include/config.php");
include_once("../include/functions/import.php");
verify_login_admin();
        
		
if($_REQUEST['update'] == "success")
{
	$message = "Administrator Successfully Edited";
	Stemplate::assign('message',$message);
	STemplate::display("administrator/show_message.tpl");
}
        
if($_REQUEST['edit_member'])
{
	$username = escape($_REQUEST['username']);
	$email = escape($_REQUEST['email']);
	$addtosql = "";
	if ($_REQUEST['newpassword'] != "")
	{
		$newpassword = escape($_REQUEST['newpassword']);
		$newpassword = md5($newpassword);
		$addtosql = "password = '".mysql_real_escape_string($newpassword)."',"; 
	}
	$ADMINID = escape($_REQUEST['ADMINID']);
	
	$query = "update administrators set
	username = '".mysql_real_escape_string($username)."',
	$addtosql
	email = '".mysql_real_escape_string($email)."'
	where ADMINID='".mysql_real_escape_string($ADMINID)."'";
	$conn->execute($query);
	header("Location: listadminsedit.php?update=success&ADMINID=$ADMINID");
}

if($_REQUEST['ADMINID']!="")
{
$ADMINID = escape($_REQUEST['ADMINID']);
$query = $conn->execute("select * from administrators where ADMINID='".mysql_real_escape_string($ADMINID)."' limit 1");
$member = $query->getrows();
Stemplate::assign('member', $member[0]);
}

Stemplate::assign('error',$error);
STemplate::display("administrator/listadminsedit.tpl");
?>