<!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>
      <?php 
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$name = mysql_real_escape_string(stripslashes($_REQUEST['name']));
$city = mysql_real_escape_string(stripslashes($_REQUEST['city']));
$country = mysql_real_escape_string(stripslashes($_REQUEST['country']));
$email = mysql_real_escape_string(stripslashes($_REQUEST['email']));
$comments = mysql_real_escape_string(stripslashes($_REQUEST['comments']));
$publish = mysql_real_escape_string(stripslashes($_REQUEST['publish']));
$date = mysql_real_escape_string(stripslashes($_REQUEST['date']));

if  (isset($_POST['submit'])) {
	$sql="UPDATE guestbook SET name='$name', lang='$lang', city='$city', country='$country', email='$email', comments='$comments', publish='$publish', date='$date' WHERE id='$id'";
	$result = mysql_query($sql);	
?>

<meta http-equiv="refresh" content="0;URL=edit-guest.php?id=<?php echo $id ?>">
<?php
} 
else {	
			$result = mysql_query("SELECT * FROM guestbook WHERE id='$id'",$dbh);
			$myrow=mysql_fetch_array($result); 
			$id=$myrow['id'];
			$name=$myrow['name'];
			$lang=$myrow['lang'];
			$city=$myrow['city'];
			$country=$myrow['country'];
			$email=$myrow['email'];
			$comments=$myrow['comments'];
			$rate=$myrow['rate'];
			$publish=$myrow['publish'];
			$date=$myrow['date'];
			?>
            
<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">
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Όνομα
        </td>
      <td> 
        <input type="text" name="name" size="100" value="<?php echo $name ?>" class="forms">
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Από</td>
      <td>
      Ελλάδα 
        <?php if ($lang=='yes') { ?>
        <input name="lang" type="radio" id="lang" value="yes" checked>
        <?php }else{?>
        <input name="lang" type="radio" id="lang" value="yes">     
        <?php } ?>
        
        &nbsp; &nbsp; &nbsp;
        
        Εξωτερικό
        <?php if ($lang=='no') { ?>
        <input name="lang" type="radio" id="lang" value="no" checked>
        <?php }else{?>
        <input name="lang" type="radio" id="lang" value="no">     
        <?php } ?>
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Πόλη<br></td>
      <td><input type="text" name="city" class="forms" size="100" value="<?php echo $city ?>" maxlength="60"></td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Χώρα</td>
      <td><input type="text" name="country" class="forms" size="100" value="<?php echo $country ?>" maxlength="60"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>E-mail</td>
      <td><input type="text" name="email" class="forms" size="100" value="<?php echo $email ?>" maxlength="60"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Κείμενο</td>
      <td><textarea name="comments" cols="100" rows="10" class="forms"><?php echo $comments ?></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Ημερομηνία</td>
      <td><input type="text" name="date" class="forms" size="20" maxlength="10" value="<?php echo $date ?>"></td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Δημοσίευση στο site?</td>
      <td> 
        <select name="publish" class="forms">
          <?php if ($publish==yes) { ?>
          <option value="yes" selected>yes</option>
          <option value="no">no</option>
          <?php }else{?> 
          <option value="no" selected>no</option>
          <option value="yes">yes</option>
          <?php } ?>
</select>
        </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-guests.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
