<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Web management</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<?php include 'codes.php';?>
</head>
<body text="#000000" style="margin:0">
      <?php 
$colour = mysql_real_escape_string(stripslashes($_REQUEST['colour']));
$pantone = mysql_real_escape_string(stripslashes($_REQUEST['pantone']));
			
if  (isset($_POST['submit'])) {
             $nu_row = '0';
              $zero='0';
			
			$sql2 = "SELECT * FROM  colors WHERE pantone='$pantone' AND id NOT LIKE '$id'";
			$result2= mysql_query($sql2);
			$nu_row = mysql_num_rows($result2);
?>
  <?php 
	if  ( ( $nu_row==0)) {
	?>
  <?php 
			
			$sql = "UPDATE colors SET  colour='$colour', pantone='$pantone' WHERE id='$id'";
			$result = mysql_query($sql);
?>
<meta http-equiv="refresh" content="0;URL=all-colors.php">
<?php } else {?>
<div align="center" class="text"> Αυτό το χρώμα υπάρχει ήδη στην λίστα χρωμάτων. Επιλέξτε 
        άλλο χρώμα. </div><?php } ?>
<?php
} else {	
			$result = mysql_query("SELECT * FROM colors WHERE id='$id'",$dbh);
			$myrow=mysql_fetch_array($result); 
			$id=$myrow['id'];
			$colour=$myrow['colour'];
			$pantone=$myrow['pantone'];
?>

<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div><img src="img/frame-edit.png" width="180" height="37" alt=""></div>
<div class="frame">

<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
  <input type="hidden" name="id" value="<?php echo $id ?>">
  <table width="100%" border="0" cellspacing="0" cellpadding="4" class="text">
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Χρώμα*
        </td>
      <td><input type="text" name="colour" maxlength="30" size="40" value="<?php echo $colour ?>" class="forms"></td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Κωδικός χρώματος*</td>
      <td>#
        <input type="text" name="pantone" class="forms" size="12" value="<?php echo $pantone ?>" maxlength="6"></td>
    </tr>
    </table>

  <div align="center" style="padding:5px">
   <input type="submit" name="submit" value="Καταχώρηση" class="button">
        <input type="reset" name="reset" value="Επαναφορά" class="button">  </div>
</form>  
</div>
<div align="right"><a href="all-colors.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
