<table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                      
                <td>
                <div class="trigger"> <?php echo $fieldguestbook ?> </div>
                <div class="toggle-container" style="padding-top:10px"> 
             <!--FORM --> 
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr> 
                      <td> 
    <?php require_once 'fprotect.php'; ?>
           
<?php
date_default_timezone_set(EST);
$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']));
$rate = mysql_real_escape_string(stripslashes($_REQUEST['rate']));
$date = mysql_real_escape_string(stripslashes($_REQUEST['date']));
 
	if  (isset($_POST['submit'])) {
    $name=safe($name);
	$city=safe($city);
    $country=safe($country); 
    $email=safe($email); 
    $comments=safe($comments); 
    $code1=safe($code1); 
	?>
	
   	<?php
if (preg_match("/a href/i", "$comments")) {
?> 
<?php } else { ?>

<?php if ($_REQUEST['data']==$_POST['code1']) { ?>

<?php
$sql = "INSERT INTO guestbook  (name, lang, city, country, email, comments, rate, date) VALUES ('$name', 'no', '$city', '$country', '$email', '$comments', '$rate', '$date')";
$result = mysql_query($sql);
			
$sql1 = "DELETE FROM guestbook WHERE name IS NULL OR comments LIKE ('%http%')";
$result1 = mysql_query($sql1);
?>

                      </td>
                    </tr>
                    <tr> 
                      <td>
                      <?php echo $fieldtext1 ?>
                      </td>
                    </tr>
                    <tr> 
                      <td><hr></td>
                    </tr>
                    <tr> 
                      <td> 
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr valign="top">
    <td width="150">
<?php echo $fieldname ?><br>
<?php echo $fieldcity ?><br>
<?php echo $fieldcountry ?><br>
E-mail<br>
<?php echo $fieldcomments ?>
    </td>
    <td> 
<?php echo $name ?><br>
<?php echo $city ?><br>
<?php echo $country ?><br>
<?php echo $email ?><br>
<?php echo $comments ?>
</td>
  </tr>
</table></td>
                    </tr>
                    <tr> 
                      <td>&nbsp;</td>
                    </tr>
                    <tr> 
                      <td> 
                        <?php } else { ?>
                      </td>
                    </tr>
                    <tr> 
                      <td>
                   <a href="guestbook.php"><?php echo $fieldtext2 ?></a> 
                      </td>
                    </tr>
                    <tr> 
                      <td> 
                        <?php } ?>
                        <?php } ?>
                        <?php } else { ?>
                      </td>
                    </tr>
                    <tr> 
                    
                        <td> 
                        <form name="forma" method="post" action="">	
                        <input type="hidden" name="date" value="<?php echo date ("j.m.Y") ?>">
                          <table width="100%" border="0" cellpadding="0" cellspacing="2">
                            <tr valign="top"> 
                              <td>
               <?php echo $fieldname ?> *
                              </td>
                              <td><input type="text" name="name" id="name" class="forms" size="28" maxlength="50"></td>
                            </tr>
                            <tr valign="top">
                              <td><?php echo $fieldcity ?></td>
                              <td><input type="text" name="city" id="city" class="forms" size="28" maxlength="50"></td>
                            </tr>
                            <tr valign="top"> 
                              <td>
               <?php echo $fieldcountry ?>   
                              *</td>
                              <td><input type="text" name="country" id="country" class="forms" size="28" maxlength="50"></td>
                            </tr>
                            <tr valign="top">
                              <td>E-mail</td>
                              <td><input type="text" name="email" id="email" class="forms" size="28" maxlength="60"></td>
                            </tr>
                            <tr valign="top">
                              <td><?php echo $fieldcomments ?>*</td>
                              <td><textarea name="comments" id="comments" class="forms" rows="5" cols="22"></textarea></td>
                            </tr>
                            <tr>
                              <td><img src="<?php echo $sitepath ?>images/rate.png" alt=""></td>
                              <td>
                              <table border="0" cellspacing="0" cellpadding="2">
                                        <tr> 
                                          <td align="center"> 
                                            none
                                          </td>
                                          <td align="center"> 
                                            
                                      1
                                          </td>
                                          <td align="center"> 
                                            2
                                          </td>
                                          <td align="center"> 
                                            3
                                          </td>
                                          <td align="center"> 
                                            4
                                          </td>
                                          <td align="center"> 
                                            5
                                          </td>
                                          <td align="center"> 
                                            6
                                          </td>
                                          <td align="center">7</td>
                                          <td align="center">8</td>
                                          <td align="center">9</td>
                                          <td align="center">10</td>
                                        </tr>
                                        <tr> 
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="0" checked>
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="1">
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="2">
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="3">
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="4">
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="5">
                                            
                                          </td>
                                          <td align="center"> 
                                             
                                              <input type="radio" name="rate" value="6">
                                            
                                          </td>
                                          <td align="center"><input type="radio" name="rate" value="7"></td>
                                          <td align="center"><input type="radio" name="rate" value="8"></td>
                                          <td align="center"><input type="radio" name="rate" value="9"></td>
                                          <td align="center"><input type="radio" name="rate" value="10"></td>
                                        </tr>
                                      </table>
                              </td>
                            </tr>
                            <tr valign="top">
                              <td>
                           
                              <?php echo $fieldcode ?>
<?
global $data;
$data = mt_rand(100000,1000000);
?>
                                <input type="hidden" name="code1" value="<?php echo $code1 ?>">
                                <input type="hidden" name="data" value="<?php echo $data ?>">
                                
                         </td>
                              <td>
                              
                              <img src="<?php echo $sitepath ?>includes/dynamicimage.php?dt=<? global $data; echo base64_encode($data);?>" alt="">
                              <input type="text" name="code1" id="code1" size="8" class="forms" maxlength="6" >
                              
                              </td>
                            </tr>
                            <tr valign="top">
                              <td>* <?php echo $fieldrequired ?></td>
                              <td><input name="submit" type="submit" class="button" onClick="MM_validateForm('name','','R','country','','R','email','','NisEmail','comments','','R');return document.MM_returnValue" value="<?php echo $button2 ?>"></td>
                            </tr>
                          </table>
						  </form>
                      </td>
                    </tr>
                    <tr> 
                      <td> 
              <?php } ?>
                </td>
                    </tr>
                  </table>   
                </div>
                <hr>

                </td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
              <tr> 
                <td> 
                  <?php 
			$sql = "SELECT * FROM guestbook WHERE publish='yes'";
			$result = mysql_query($sql);
			$num_rows = mysql_num_rows($result);
?>
  <?php 
$start = mysql_real_escape_string($_REQUEST['start']);
?>
                  <?php if ($start=='') { 
$start=$num_rows*10;
}?>
                  <?php
			$sql1 = "SELECT * FROM guestbook WHERE publish='yes' AND id<'$start' ORDER BY id desc LIMIT 10";
			$result1 = mysql_query($sql1);
			while ($myrow=mysql_fetch_array($result1)) {
			$id=$myrow['id'];
			$name=$myrow['name'];
			$lang=$myrow['lang'];
			$city=$myrow['city'];
			$country=$myrow['country'];
			$email=$myrow['email'];
			$comments=$myrow['comments'];
			$rate=$myrow['rate'];
			$date=$myrow['date'];
			$ppriority=$myrow['id'];
?>
                </td>
              </tr>
              <tr> 
                <td valign="top"> 
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr> 
                                  
                            <td><span class="titles"> 
                              <?php echo $name ?>
                              </span> 
                              <?php echo $city  ?>
                              
                              <?php echo $country  ?>
                            </td>
                                  <td width="100" align="right"> 
                                      <?php  echo $date ?>
                                  </td>
                                  <td width="50" align="right">
                                   <?php if ($rate>0) { ?>
                                <span class="titles">
                               <img src="<?php echo $sitepath ?>images/rate.png" alt=""> <?php echo $rate ?>
                                </span>
                                <?php }?>
                                  </td>
                                </tr>
                              </table>
 <hr>
<?php echo $comments ?>
          
                </td>
              </tr>
              <tr> 
                <td>&nbsp;</td>
              </tr>
              <tr> 
                <td> 
                  <?php			
	}
?>
                </td>
              </tr>
              <tr> 
                <td align="center"> 
                  <?php 
			$sql2 = "SELECT * FROM guestbook WHERE lang='no' AND publish='yes' AND id>'$start' ORDER BY id LIMIT 10";
			$result2 = mysql_query($sql2);
			while ($myrow=mysql_fetch_array($result2)) {
			$ppriority1=$myrow['id'];
}?>
                  <?php 
			$sql3 = "SELECT * FROM guestbook WHERE lang='no' AND publish='yes' AND id>'$ppriority1' ORDER BY id LIMIT 1";
			$result3 = mysql_query($sql3);
			$num_prev = mysql_num_rows($result3);
?>
                  <?php if ($num_prev==0 AND $num_rows>0) { 
$startpr=$ppriority1+1;
} else {
$startpr=$ppriority1;
}?>
                  <?php if ($startpr!='') { ?>
                  <a href="guestbook.php?start=<?php echo $startpr ?>"><img src="<?php echo $sitepath ?>images/prev.png" alt="previous"></a> &nbsp; 
                  <?php } ?>
                  <?php
			$sql4 = "SELECT * FROM guestbook WHERE lang='no' AND publish='yes' AND id<'$ppriority'";
			$result4 = mysql_query($sql4);
			$num_items = mysql_num_rows($result4);
?>
                  <?php 
	if  ( ( $num_items!=0)) {
	?>
                  <a href="guestbook.php?start=<?php echo $ppriority ?>"><img src="<?php echo $sitepath ?>images/next.png" alt="next"></a> 
                  <?php } ?>
                </td>
              </tr>
            </table>