<? include_once("../includes/main.inc.php");

$page_id = $_REQUEST['page_id'];

$country_id = '1';

if(is_post_back()) {

	if($page_id!='') {		 

		$sql = "update `tbl_state` set country_id='".addslashes($country_id)."', state_name='".addslashes($state_name)."', state_short_name='".addslashes($state_short_name)."', state_status='".addslashes($state_status)."', title='".addslashes($title)."', description='".addslashes($description)."', keyword='".addslashes($keyword)."' where state_id = $page_id ";

		db_query($sql);

		set_session_msg("state records updated successfully.");	

    	} 
    	else
    	{	

		$sql = "insert into `tbl_state` set state_name='".addslashes($state_name)."', state_status='".addslashes($state_status)."', state_short_name='".addslashes($state_short_name)."', country_id='".addslashes($country_id)."', title='".addslashes($title)."', description='".addslashes($description)."', keyword='".addslashes($keyword)."'";

		db_query($sql);
		set_session_msg("New state records added successfully.");

	}

	header("Location: district.php?start=$start");

	exit;

}

$page_id = $_REQUEST['page_id'];

if($page_id!='') {

	$sql = "select `tbl_state`.*,`tbl_country`.country_name,`tbl_state`.state_status,`tbl_state`.country_id from `tbl_state` join `tbl_country` on `tbl_state`.country_id=`tbl_country`.country_id where state_id = '$page_id'";

	$result = db_query($sql);

	if ($line_raw = mysql_fetch_array($result)) {

		@extract($line_raw);

	}

}

?>

<link href="styles.css" rel="stylesheet" type="text/css">

<? include("top.inc.php");?>

<table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td id="pageHead"><div id="txtPageHead">

       Add/Edit State</div></td>

  </tr>

</table>

<script type="text/javascript" src="fckeditor/fckeditor.js"></script>

<table width="80%" align="left">

		  	<tr><td>

		  	<form method="post" action="" enctype="multipart/form-data" name="form1" id="form1" onSubmit="return validate(this);">

        <table width="80%" align="center" border=0 cellpadding="0"  cellspacing="0" class="text">

    	<tr>

		<td  colspan="2"height="30"  align="right"><a href="district.php?start=<?=$start?>" class="redcolor"><strong>Back To State List</strong></a></td>

		</tr>    

        <tr><td height="15"><div align="center"><span class="msg"><?=display_sess_msg();?></span></div><br /></td></tr>  

		
<tr>
<td class="lables"><b>State Name</b></td>
<td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($state_name)?>" name="state_name" id="state_name"  /></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>State Short Name</b></td>
<td class="feildstxt"><input type="text" style="width:300px;" value="<?=stripslashes($state_short_name)?>" name="state_short_name" id="state_short_name"  /></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables"><b>Status</b></td>
<td class="feildstxt"><select name="state_status" id="state_status">
<option value="1" <?php if($state_status=='1'){ echo 'selected="selected"'; } ?>>Active</option>
<option value="0" <?php if($state_status=='0'){ echo 'selected="selected"'; } ?>>InActive</option>          
</select></td>
</tr>

<tr><td>&nbsp;</td></tr>

<tr>
<td class="lables" colspan="2"><hr/></td>
</tr>


<tr><td>&nbsp;</td></tr>

<tr>
<td align="left" class="lables">&nbsp;</td>
<td align="left" class="feildstxt"><input class="button" type="submit" name="submit" value="Save"></td>
</tr>

<tr><td height="25">&nbsp;</td></tr>

   </table>

    </form>

    </td></tr></table>   
   
  <? include("bottom.inc.php");?>