<?
session_start();
if(strlen($brcode)<=0)
{
 print "<script> alert('Session timed out'); parent.document.location='../../ind.php'; </script>";
 return;
}
include("../../opendb.php");
include("../../test.php");
if($save)
{
 $re=mysqli_query($db,"select * from insurco where cname='$cname' and brcode='$brcode'");
 if(mysqli_num_rows($re)>0)
 {
   print "<script> alert('Duplicate Entry'); history.back(1); </script>"; 
   return;
 }

 $sql="insert into insurco (cname,addr,city,cnt,mob,brcode) values('$cname','$addr','$city','$cnt', '$mob','$brcode')";
 mysqli_query($db,$sql) or die(mysqli_error());
}
?>
<style>
body,td{font-family:'arial narrow';letter-spacing:1;}
tr{background-color:e3ecd2}
th{background-color:c1d799}
.mnu{margin-left:5}
body{BACKGROUND-COLOR:fcfff1}

</style>
<script>
 function valid()
 {
   if(document.f1.cname.value.length<=0)
   {
     alert('Invalid Company Name'); 
     document.f1.cname.focus();
     return false;
   }
}
</script>

<center>
<form action='<?print $PHP_SELF?>' name='f1' method='post' onSubmit="return valid()">
<fieldset style="width:500;color:red;border-color:black">
<legend>
<font size=3><B>NEW INSURANCE COMPANY</B></FONT></legend>
<table cellspacing=1 cellpadding=4 class=x>
<TR><TD>Company Name </td><td><input type=text name='cname' size=40></td></tr>
<TR><TD>Address</td><td><input type=text name='addr' size=40></td></tr>
<TR><TD>City</td><td><input type=text name='city' size=40></td></tr>
<TR><TD>Contact No/Name </td><td><input type=text name='cnt' size=40></td></tr>
<TR><TD>Mobile Numbers </td><td><input type=text name='mob' size=40></td></tr>
<tr><td colspan=2 align=center bgcolor='lightsteelblue'>
 <input type=submit value='Save' name='save'>
</td></tr>
</table>
</fieldset>
</form>
<br>
<font size=3><B>INSURANCE COMPANIES</B></FONT></legend>
<table cellspacing=2 cellpadding=4>
<th>No. <th>Name <th>Address <th>City <th>Contact <th>Mobile<th>Edit
<?
 $i=1;
 $re=mysqli_query($db,"select * from insurco where brcode='$brcode' order by cname");
 while($row=mysqli_fetch_array($re))
 {
   print "<tr><td>".$i++."</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td>";
   print "<td>$row[5]</td><td><input type=button value='Edit'></td></tr>";
 }
?>
</table>


