<?php session_start();?>
<?php include("Header.php"); ?>
<?php require_once('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">UPDATE VENDOR DATA</h2>

<?php
       $vendor_id = $_REQUEST['vendor_id'];

       $sql = "SELECT * FROM tbl_dir_vendor WHERE vendor_id = '$vendor_id'";														
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $vendor_id=$row['vendor_id'];
				
				
		?>
				
<form  method="POST">
<table border=0 align=center  class="imagetable" >
<tr><td>Vendor Name</td><td> : </td><td><input type="text" size="100" name="vendor_name" value="<?php echo $row['vendor_name']?>"></td></tr>
<tr><td>Address</td><td> : </td><td><input type="text" size="100" name="vendor_address1" value="<?php echo $row['vendor_address1']?>">
</td></tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" name="vendor_address2" value="<?php echo $row['vendor_address2']?>"></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" name="vendor_address3" value="<?php echo $row['vendor_address3']?>"></td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td><input type="text" size="100" name="vendor_address4" value="<?php echo $row['vendor_address4']?>">;</td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
  <td>&nbsp;</td>
</tr>
<tr><td>Contact</td><td> : </td><td><input type="text" size="50" name="vendor_contact" value="<?php echo $row['vendor_contact']?>"></td></tr>
<tr><td>H/phone</td><td> : </td><td><input type="text" size="11" name="vendorhp1" value="<?php echo $row['vendor_hp1']?>"></td></tr>
<tr><td>Fax</td><td> : </td><td><input type="text" size="20" name="vendor_fax" value="<?php echo $row['vendor_fax']?>"></td></tr>
<tr><td>Email</td><td> : </td><td><input type="text" size="20" name="vendor_email" value="<?php echo $row['vendor_email']?>"></td></tr>
<tr><td>Section</td><td> : </td><td><input type="text" size="20" name="vendor_section" value="<?php echo $row['vendor_section']?>"></td></tr>
<tr><td colspan="3" align="center">
<input type="submit" class="myButton" value="UPDATE" id="save" name="save">
<input type="button" class="myButton" value="vendor LIST" onClick="window.location.href='vendor_admin.php'">
</td></tr>
</table>
<input type="hidden" name="vendor_id" value="<?php echo $row['vendor_id'] ?>">
</form>
	
	<?php
// escape variables for security
if (isset($_POST['save'])){
       $vendor_name = $_POST['vendor_name'];
    $vendor_address1 =$_POST['vendor_address1'];
	$vendor_address2 =$_POST['vendor_address2'];
	$vendor_address3 =$_POST['vendor_address3'];
	$vendor_address4 =$_POST['vendor_address4'];
     $vendor_contact = $_POST['vendor_contact'];
         $vendor_hp1 = $_POST['vendor_hp1'];
         $vendor_fax =$_POST['vendor_fax'];
       $vendor_email = $_POST['vendor_email'];
     $vendor_section = $_POST['vendor_section'];

// insert record into database
$sql="update tbl_dir_vendor set vendor_name='$vendor_name',vendor_address1='$vendor_address1',vendor_address2='$vendor_address2',
      vendor_address3='$vendor_address3',vendor_address4='$vendor_address4',vendor_contact='$vendor_contact',
	  vendor_hp1='$vendor_hp1',vendor_fax='$vendor_fax', vendor_email='$vendor_email',vendor_section='$vendor_section' where vendor_id='$vendor_id'";

$result=mysql_query($sql);
if($result)
echo "<script language='javascript'>window.location='vendor_admin.php'</script>";

else
   
   echo 'Unsuccessfull update';
   }
?>

		