<?php include 'header.php'; 
      include 'open_connection.php'; ?>

<link href='blue/style.css' rel='stylesheet' type='text/css' />

<style>
.myButton {
	-moz-box-shadow:inset 0px 1px 3px 0px #91b8b3;
	-webkit-box-shadow:inset 0px 1px 3px 0px #91b8b3;
	box-shadow:inset 0px 1px 3px 0px #91b8b3;
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #768d87), color-stop(1, #6c7c7c));
	background:-moz-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-webkit-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-o-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:-ms-linear-gradient(top, #768d87 5%, #6c7c7c 100%);
	background:linear-gradient(to bottom, #768d87 5%, #6c7c7c 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#768d87', endColorstr='#6c7c7c',GradientType=0);
	background-color:#768d87;
	-moz-border-radius:5px;
	-webkit-border-radius:5px;
	border-radius:5px;
	border:1px solid #566963;
	display:inline-block;
	cursor:pointer;
	color:#ffffff;
	font-family:arial;
	font-size:12px;
	font-weight:bold;
	padding:4px 20px;
	text-decoration:none;
	text-shadow:0px -1px 0px #2b665e;
}
.myButton:hover {
	background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #6c7c7c), color-stop(1, #768d87));
	background:-moz-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-webkit-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-o-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:-ms-linear-gradient(top, #6c7c7c 5%, #768d87 100%);
	background:linear-gradient(to bottom, #6c7c7c 5%, #768d87 100%);
	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#6c7c7c', endColorstr='#768d87',GradientType=0);
	background-color:#6c7c7c;
}
.myButton:active {
	position:relative;
	top:1px;
}
table.imagetable {
	font-family: verdana,arial,sans-serif;
	font-size:11px;
	color:#333333;
	border-width: 1px;
	border-color: #999999;
	border-collapse: collapse;
}
table.imagetable th {
	background:#b5cfd2 url('cell-blue.jpg');
	border-width: 1px;
	padding: 5px;
	border-style: solid;
	border-color: #999999;
}
table.imagetable td {
	background:#dcddc0 url('cell-grey.jpg');
	border-width: 1px;
	padding:5px;
	border-style: solid;
	border-color: #999999;
}
       
</style>

<h2 align="center">INSERT VENDOR RECORD</h2>

<form  method="post">
<table align="center"  class="imagetable">
<tr><td>Vendor Name</td><td> : </td><td><input type="text" size="100" maxlength="100" name="vendor_name"></td></tr>
<tr><td>Address</td><td> : </td><td><input type="text" size="100" maxlength="100" name="vendor_address1"></td></tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" maxlength="100" name="vendor_address2" /></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" maxlength="100" name="vendor_address3" /></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" maxlength="100" name="vendor_address4" /></td>
</tr>
<tr><td>Contact</td><td> : </td><td><input type="text" size="50" maxlength="50" name="vendor_contact"></td></tr>
<tr><td>H/P</td><td> : </td><td><input type="text" size="11" maxlength="11" name="vendor_hp1"></td></tr>
<tr><td>Fax</td><td> : </td><td><input type="text" size="20" maxlength="20" name="vendor_fax"></td></tr>
<tr><td>Email</td><td> : </td><td><input type="text" size="20" maxlength="20" name="vendor_email"></td></tr>
<tr><td>Section</td><td> : </td><td>  <select name="vendor_section" class="input-xlarge">
                                   <option selected="selected">--Please Select-- </option>
                                   
                            <?php
                                $section_query=mysql_query("select * from tbl_ref_section order by section_id")or die(mysql_error());
                                while($row=mysql_fetch_array($section_query)){
                            ?>
                            <option>
                                 <?php
                                     echo $row['section_name'];
                                 ?>
                            </option>
                            <?php
                                }
                            ?>
                            </select></td></tr>
							
							<tr><td>Category</td><td> : </td><td>  <select name="vendor_category" class="input-xlarge">
                                   <option selected="selected">--Please Select-- </option>
                                   
                            <?php
                                $category_query=mysql_query("select * from tbl_ref_category order by category_id")or die(mysql_error());
                                while($row=mysql_fetch_array($category_query)){
                            ?>
                            <option>
                                 <?php
                                     echo $row['category_name'];
                                 ?>
                            </option>
							
                            <?php
                                }
                            ?>
							</select></td></tr>
							
<tr><td colspan="3" align="center"><input type="submit" value="INSERT" id="save" name="save" class="myButton">
<input type="button" class="myButton" value="VENDOR LIST" onClick="window.location.href='vendor_admin.php'"></td></tr>
</table>
</form>
<?php
// escape variables for security
if (isset($_POST['save'])){
$vendor_name = mysql_real_escape_string($_POST['vendor_name']);
$vendor_address1 = mysql_real_escape_string($_POST['vendor_address1']);
$vendor_address2 = mysql_real_escape_string($_POST['vendor_address2']);
$vendor_address3 = mysql_real_escape_string($_POST['vendor_address3']);
$vendor_address4 = mysql_real_escape_string($_POST['vendor_address4']);
$vendor_contact = mysql_real_escape_string($_POST['vendor_contact']);
$vendor_hp1 = mysql_real_escape_string($_POST['vendor_hp1']);
$vendor_fax = mysql_real_escape_string($_POST['vendor_fax']);
$vendor_email = mysql_real_escape_string($_POST['vendor_email']);
$vendor_section = mysql_real_escape_string($_POST['vendor_section']);
$vendor_category = mysql_real_escape_string($_POST['vendor_category']);

// insert record into database
$sql="INSERT INTO tbl_dir_vendor (vendor_name, vendor_address1, vendor_contact, vendor_hp1, vendor_fax, vendor_email, vendor_section, vendor_category)
VALUES ('".$vendor_name."', '".$vendor_address1."', '".$vendor_contact."', '".$vendor_hp1."', '".$vendor_fax."', '".$vendor_email."', '".$vendor_section."', '".$vendor_category."')";

if (!mysql_query($sql)) {
  die('Error: ' . mysql_error($conn));
} else {
echo "<script> alert('1 record added!');window.location.href='vendor_admin.php';</script>";
}
}

mysql_close($conn);
?>


<?php include("footer.php"); ?>
