<?
session_start();
include("../opendb.php");
if($submit)
{
$sql="update branch set brname='$brname',brman='$brman',braddr='$braddr',brcity='$brcity',brphone='$brphone',brpass='$brpass1',brtype='$btype',tin='$tin',cstno='$cst',brstate='$brstate' where brcode='$code'";
 mysqli_query($db,$sql) or die(mysqli_error());
print("<script>window.close(); opener.document.location='createbr.php';</script>");
}

$result=mysqli_query($db,"select * from branch where brcode='$code'");
$row=mysqli_fetch_array($result)or die(mysqli_error());
?>
<script>
resizeTo(500,550);
</script>

<link rel="stylesheet" href="style.css" type="text/css" />
<script>
function validate()
{
var p1=document.f1.brpass1.value
var p2=document.f1.brpass2.value

 submit="true";
 if(document.f1.brname.value.length<3)
  {submit="false"; alert('Invalid branch name');}

 if(document.f1.brpass1.value.length<=0)
  {submit="false"; alert('Invalid Password');}

 if(document.f1.brpass2.value.length<=0)
  {submit="false"; alert('Invalid Password2');}
 if(p1!=p2)
  {submit="false"; alert('Passwords does not match');}

 if(submit=="false")
  return false;
}
</script>

<body bgcolor=fcfff1>
<font color=green>
<h3>Branch Updation</h3></font>
<hr bgcolor=red>
<center>
<form name='f1' action='<?print $PHP_SELF?>' method='post' onSubmit="return validate()">
<input type=hidden name=code value='<?print $code?>'>
<table border=0  cellspacing=2 cellpadding=5>
<tr><td>Branch Name</td><td><input type=text name='brname' size=40 value='<?print $row[brname]?>'></td></tr>
<tr><td>Branch Type </td><td><select name='btype'>
<option><?print $row[brtype]?></option>
<option>Eicher</option>
<option>Telecon</option>
</select></td></tr>

<tr><td>Branch Manager</td><td><input type=text name='brman' size=40 value='<?print $row[brman]?>'></td></tr>
<tr><td>Address</td><td><input type=text name='braddr' size=40 value='<?print $row[braddr]?>'></td></tr>
<tr><td>City</td><td><input type=text name='brcity' size=40 value='<?print $row[brcity]?>'></td></tr>
<tr><td>State</td><td>
<select name='brstate'>
<option><?print $row[brstate]?></option>
<option>Kerala</option>
<option>Karnataka</option>
</select>
</td></tr>
<tr><td>Phone</td><td><input type=text name='brphone' size=40 value='<?print $row[brphone]?>'></td></tr>
<tr><td>Tin No.</td><td><input type=tex name='tin' size=40 value='<?print $row[tin]?>'></td></tr>
<tr><td>Cst No.</td><td><input type=text name='cst' size=40 value='<?print $row[cst]?>'></td></tr>
<tr><td>Admin Password</td><td><input type=password name='brpass1' size=40 value='<?print $row[brpass]?>'></td></tr>
<tr><td>Confirm <br>Admin Password</td><td valign=bottom><input type=password name='brpass2' size=40 value='<?print $row[brpass]?>'></td></tr>
<tr><td colspan=2 align=center><input type=submit name='submit' value='  S A V E  '> <input type=button value='   C A N C E L    ' onClick=window.close()></td></tr>
</table>
</form>


