<?php require_once 'protect.php'; ?>
<div class="trigger"><div class="titles4 color3"><?php echo $textreviews ?></div></div>
<div class="toggle-container tablew margtop20"> 
<?php
if (!$id) {
$id=0;
}
if (isset($_POST['submitreview'])) {
$name = $mysqli->real_escape_string(strip_tags($_REQUEST['name']));
$name = mb_convert_case($name, MB_CASE_TITLE, "UTF-8");
$name = preg_replace('/\s+/', ' ',$name);
$city = $mysqli->real_escape_string(strip_tags($_REQUEST['city']));
$city = mb_convert_case($city, MB_CASE_TITLE, "UTF-8");
$country = $mysqli->real_escape_string(strip_tags($_REQUEST['country']));
$country = mb_convert_case($country, MB_CASE_TITLE, "UTF-8");
$email = $mysqli->real_escape_string(strip_tags($_REQUEST['email']));
$email = strtolower($email);
$email = preg_replace('/\s+/', '',$email);
$comments = $mysqli->real_escape_string(strip_tags($_REQUEST['comments']));
$comments = $mysqli->real_escape_string(stripslashes($_REQUEST['comments']));
$comments = str_replace('\r\n', ' ',$comments);
$comments = preg_replace('/\s+/', ' ',$comments);
$rate = $mysqli->real_escape_string(strip_tags($_REQUEST['rate']));
$date = date ("j.m.Y");

$result = $mysqli->query("SELECT insert_id FROM categories WHERE type=4 AND priority=3 GROUP BY lang_id LIMIT 1");
$row = $result->fetch_array(); 
$rcid=$row['insert_id'];
		
if ($_REQUEST['notes']=='' AND $name!=' ' AND $name!='' AND (filter_var($email, FILTER_VALIDATE_EMAIL)) AND $_REQUEST['data']==$_POST['code1']) {
	
$mysqli->query("INSERT INTO members (category_id, item_id, name, city, country, email, comments, rate, date) VALUES ('$rcid', '$id', '$name', '$city', '$country', '$email', '$comments', '$rate', '$date')");
$mysqli->query("DELETE FROM members WHERE name IS NULL OR comments LIKE ('%http%')");			
?>
<hr>
<div>
<?php echo $fieldname ?>: <?php echo $name ?><br>
<?php echo $fieldcity ?>: <?php echo $city ?><br>
<?php echo $fieldcountry ?>: <?php echo $country ?><br>
<?php echo $email ?><br> 
<?php echo $fieldcomments ?>: <?php echo $comments ?>
</div>
<?php } else { ?>
<a href="javascript:history.go(-1);"><?php echo $fieldtext2 ?></a>
<?php } ?>
<?php } else { ?> 
<form name="forma" method="post">
<label for="name" class="hlabel"><?php echo $fieldname ?>*</label>
<input type="text" name="name" id="name" placeholder="<?php echo $fieldname ?>*" size="20" maxlength="50" class="inputauto" required>
<label for="city" class="hlabel"><?php echo $fieldcity ?></label>
<input type="text" name="city" id="city" placeholder="<?php echo $fieldcity ?>" size="15" maxlength="50" class="inputauto">
<label for="country" class="hlabel"><?php echo $fieldcountry ?>*</label>
<input type="text" name="country" id="country" placeholder="<?php echo $fieldcountry ?>*" size="15" maxlength="50" class="inputauto" required>
<div class="hiddenmail">
<label for="email" class="hlabel">Email</label>
<input type="text" name="email" id="email" placeholder="Email" size="15" maxlength="50" class="inputauto">
</div>
<div>
<label for="comments" class="hlabel"><?php echo $fieldmessage ?></label> 
<textarea name="comments" id="comments" placeholder="<?php echo $fieldcomments ?>" rows="8" cols="60" class="formsauto" required></textarea>
</div>
<table class="text-center">
<tr> 
<td><span class="icon fa-check-square color3"></span></td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
<tr> 
<td><input type="radio" name="rate" value="0" checked></td>
<td><input type="radio" name="rate" value="1"></td>
<td><input type="radio" name="rate" value="2"></td>
<td><input type="radio" name="rate" value="3"></td>
<td><input type="radio" name="rate" value="4"></td>
<td><input type="radio" name="rate" value="5"></td>
<td><input type="radio" name="rate" value="6"></td>
<td><input type="radio" name="rate" value="7"></td>
<td><input type="radio" name="rate" value="8"></td>
<td><input type="radio" name="rate" value="9"></td>
<td><input type="radio" name="rate" value="10"></td>
</tr>
</table>
<div>

<?
global $data;
$data = mt_rand(100000,1000000);
?>
<label for="code1" class="hlabel"><?php echo $fieldcode ?></label>
<input type="hidden" name="code1" value="<?php echo $code1 ?>">
<input type="hidden" name="data" value="<?php echo $data ?>">
<img src="<?php echo $codepath ?>includes/dynamicimage.php?dt=<? global $data; echo base64_encode($data);?>" alt="">
<input type="text" name="code1" id="code1" placeholder="<?php echo $fieldcode ?>" size="16" maxlength="6" class="inputcode" required>
<label class="hide">note<input type="text" name="notes" id="notes" size="1" maxlength="20" class="formsn"></label>
</div>
<div class="divsubmit"><input type="submit" name="submitreview" class="button buttonsubmit" value="<?php echo $button2 ?>"></div>
<div class="divrequired color2">* <?php echo $fieldrequired ?></div>
</form>
<?php } ?>
</div><hr class="margbottom30">