<?php
ob_start();
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com © 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
}else{
	header("Location:login.php");
	exit;
}

if(isset($_GET['form_id']) !='' )
{

	if(isset($_POST['insert']))
	{
	
		/*check whether option with the same name exists in the database*/
			
		$select_options = "SELECT option_id FROM ".$tableprefix."options WHERE LOWER(option_name) = ".GetSQLValueString(strtolower($_POST['txtoption_name']),"text");
		$result_options = mysql_query($select_options) or die(mysql_error());
		
		if(mysql_num_rows($result_options)>0)
		{
		
			$message = OPTION_EXIST." !!";
		}
		else
		{	
	
			$insert_options = "INSERT INTO ".$tableprefix."options(option_name)
									  VALUES("
									  .GetSQLValueString($_POST['txtoption_name'],"text").")";
			  
			mysql_query($insert_options) or die(mysql_error());
		
		header('Location:options.php?msg1='.OPTION_ADD_SUCCESS);
		
		}
	
	}

}
include "../includes/htmltop.php";
?>
<body topmargin="0">
<script>
function checkOptions()
{

  var form_name = new Array('txtoption_name');		
  var display_name = new Array('<?php echo OPTION_NAME;?>');
  var count = 1;	

  if(check_fields('frmOption',form_name,display_name,count))	
  {
  
  }
  else
  {
  
  		return false;
  
  }
   
}
</script>
		<body>
		<center>
		<div align="left" id="layout">
				<!--header area start -->
<?php
	include_once("../includes/topheader_admin.php")
?>
				<!--header area end -->
				<div align="left" class="main_body">
				<!--main body start -->
<?php
		include_once("../includes/admintopmenu.php")
?>		
					<div align="left" class="content_area">
					<!--content area start -->
					<div align="left" class="page_title"><?php ADD_OPTION;?> </div>
					<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            		<br>
					<div align="left">										
					<form name="frmOption" method="post" onSubmit="return checkOptions();">
					<table width="100%" border="0" cellpadding="0" cellspacing="0" class="manage_table">
					<tr><td colspan="3" align="right"><span class="required">*</span>&nbsp;<?php echo FIELDS_ARE_MANDATORY;?></td></tr>
						<tr class="whitebg">
							<td width="42%" class="" valign="top"><?php echo OPTION_NAME;?>&nbsp;<span class="required">*</span></td>
							<td width="58%" valign="top"><input type="text" name="txtoption_name" class="textarea2"></td>
						</tr>
						<tr>
							<td align="center" colspan="6">
								
                                                                <input type="submit" class="button" name="insert" value="&nbsp;<?php echo ADD_TEXT;?>&nbsp">
							</td> 
						</tr>				
					</table>	
				</form>
								
				</div>
				<!--content area end-->
				</div>
					<div align="left" class="clear_float"><img src="<?php echo $imagefolder;?>/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
<?php
	include "../includes/footer.php";
	
	ob_end_flush();
?>