<? session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../ind.php'; </script>";
 return;
}

include("../opendb.php");
if($edit)
{
 $sql="update sman_master set repname='$repname',addr1='$addr1',addr2='$addr2',city='$city', dist='$dist', stat='$stat',pin='$pin',phone1='$phone1',phone2='$phone2',email='$email' where code='$code' and branch='$brcode'";

 mysqli_query($db,$sql)or die(mysqli_error());
 include("sman-mast.php");
 return;
}
$re=mysqli_query($db,"select * from sman_master where code='$code' and branch='$brcode'");
$row=mysqli_fetch_row($re);
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:c1d7bb}
.mnu{margin-left:5}
</style>
<body bgcolor='ivory'>

<CENTER>
<BR>
<FORM ACTION='<?print $PHP_SELF?>' METHOD='POST'>
<input type=hidden name='code' value='<?print $code?>'>
<table cellspacing=1 cellpadding=1 bgcolor=green>
<tr><td align=center>
<table>
<tr><td colspan=2 align=center><STRONG>EDIT SALES MANAGER MASTER</TD></TR>
<tr><td>Rep. Name </td><td><input type=text name='repname' size=40 value='<?print $row[1]?>'></td></tr>
<tr><td>Address1 </td><td><input type=text name='addr1' size=40 value='<?print $row[2]?>'></td></tr>
<tr><td>Address2 </td><td><input type=text name='addr2' size=40 value='<?print $row[3]?>'></td></tr>
<tr><td>City </td><td><input type=text name='city' size=40 value='<?print $row[4]?>'></td></tr>
<tr><td>District </td><td><select name='dist'> 
<option><?print $row[5]?></option>

<?
$re=mysqli_query($db,"select * from dist_master  order by dist");
while($ro=mysqli_fetch_row($re))
{
 print "<option>$ro[1]</option>";
}
?></select></td></tr>
<tr><td>State </td><td><input type=text name='stat' size=40 value='<?print $row[6]?>'></td></tr>
<tr><td>Pin No </td><td><input type=text name='pin' size=40 value='<?print $row[7]?>'></td></tr>
<tr><td>Phone1 </td><td><input type=text name='phone1' size=40 value='<?print $row[8]?>'></td></tr>
<tr><td>Phone2 </td><td><input type=text name='phone2' size=40 value='<?print $row[9]?>'></td></tr>
<tr><td>Email_id </td><td><input type=text name='email' size=40 value='<?print $row[10]?>'></td></tr>
<TR><TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME = 'edit' VALUE='  UPDATE  '> <input type=button value='  CANCEL  ' onClick=history.back(1);> </TD></TR>

</table>
</td></tr>
</table>
<FORM>
