<?php 

if (isset($_POST['formaction']) && ($_POST['formaction'] == 'add' || $_POST['formaction'] == 'edit'))
{
	
	$TITLE				= trim($funcObj->AppendSlashes($_POST['txttitle']));
	$SENDER_NAME		= trim($funcObj->AppendSlashes($_POST['SENDER_NAME']));
	$SENDER_EMAIL		= trim($funcObj->AppendSlashes($_POST['SENDER_EMAIL']));
	$SENDER_COMPANY		= trim($funcObj->AppendSlashes($_POST['SENDER_COMPANY']));
	$REPLY_NAME		    = trim($funcObj->AppendSlashes($_POST['REPLY_NAME']));
	$REPLY_EMAIL		= trim($funcObj->AppendSlashes($_POST['REPLY_EMAIL']));
	$SIGNATURE			= trim($funcObj->AppendSlashes($_POST['SIGNATURE']));
	$HOST				= trim($funcObj->AppendSlashes($_POST['txthost']));
	$PORT				= trim($funcObj->AppendSlashes($_POST['txtport']));
	$USER 				= trim($funcObj->AppendSlashes($_POST['txtuser']));
	$PASSWORD 			= trim($funcObj->AppendSlashes($_POST['txtpassword']));
	$AUTHENTICATION 	= isset($_POST['chkauthentication']) ? $_POST['chkauthentication'] :'0';
	$BOUNCE_EMAIL		= trim($funcObj->AppendSlashes($_POST['txtbounce']));
	$DEFAULT 			= isset($_POST['chkdefault']) ? $_POST['chkdefault'] :'';
	$ID 				= isset($_POST['ID']) ? $_POST['ID'] :'';
	
	$error = "";
	
	if (empty($TITLE))
	{
		$error .= "Title/Name is required.<br />";
	}
	if (empty($SENDER_NAME))
	{
		$error .= "Sender Name is required.<br />";
	}
	if (empty($SENDER_EMAIL))
	{
		$error .= "Sender Email is required.<br /> ";
	}
	else if (!validate_email ($SENDER_EMAIL))
	{
		$error 	= "Invalid Sender Email. It must be in the email format.<br />";
	}
	if (empty($SENDER_COMPANY))
	{
		$error .= "Sender Company is required.<br />";
	}
	if (empty($SIGNATURE))
	{
		$error .= "Signature is required.<br />";
	}
	
	if (empty($HOST))
	{
		$error .= "SMTP host name is required.<br /> ";
	}
	if (empty($PORT))
	{
		$error .= "SMTP port is required.<br /> ";
	}
	else if (!is_numeric($PORT))
	{
		$error .= "Port number must be a numeric value.<br /> ";
	}
	if (empty($USER))
	{
		$error .= "SMTP user is required.<br /> ";
	}
	else if (!validate_email ($USER))
	{
		$error 	= "Invalid user. It must be in the email format.<br />";
	}
	if (($_POST['formaction'] == 'add') || (!empty($PASSWORD)))
	{
		if (empty($PASSWORD))
		{
			$error .= "Password cannot be left blank.<br /> ";
		}
	}
	if (strlen($error))
	{
		$errorMsg = "<strong>Please correct the following error(s):</strong> <br />
		$error";
	}
}
?>