﻿<?php
	include "header.php";
	include "functions.php";

	$error = "";
	if (isset($contact))
	{
		//в форму переданы данные

		if (empty($name)) $error .= "<P>Имя не введено";
		elseif (strstr($name," ")==FALSE) $error .= "<P>Введите хотя бы фамилию и имя";

		$checkemail = checkmail($email);
		if ($error != "") $error .= ",<br>";
		if ($checkemail == 1) $error .= "E-mail не введен";
		if ($checkemail ==-1) $error .= "E-mail неправильный";

		if ($error != "") $error .= ",<br>";
		if (empty($message)) $error .= "Вы пытаетесь отправить пустое сообщение";

	}

	if (isset($contact) && ($error==""))
	{
		$name = converthtml($name);
		$message = converthtml($message);
		$datecreate = date("d.m.Y H:i");
		$subj = '[yabloko.ru] Форма обратной связи - Сообщение от '.$datecreate;
		$body = "$datecreate\n\r$name <$email> пишет:\n\r$message";
		mail($admemail,$subj,$body);
?>
<h1>Спасибо!</h1>
	<div id="form" style="height:400px">
Ваше сообщение успешно отправлено!
	</div>
<?php

	}
	else {
?>
		<h1>Обратная связь</h1>

<div id="form" style="height:400px">
		<p style="margin-bottom: 1em;">Здесь вы можете оставить сообщение координаторам этого сайта.</p>
		<?php if($error != "") echo '<p style="margin-bottom: 1em;"><font color="red">'.$error.'</font></p>'; ?>
		<form id="f" action="/zakonfsb/contact.php" method="post" style="margin-top:.3em">

			<table>
					<td class="l" width="40">Имя</td>
					<td class="i"><input name="name" maxlength="40"  class="required" autocomplete="off" id="input-name" value="<?php echo $name;?>"/></td>
				</tr>
				<tr>
					<td class="l">E-mail</td>
					<td class="i"><input name="email" id="input-email" class="required" autocomplete="off" value="<?php echo $email;?>"/><br /></td>
				</tr>
				<tr>
					<td colspan="2" class="i"><textarea class="required" style="width:440px" cols="23" rows="7" name="message" id="input-message"><?php echo $message;?></textarea></td></tr>
				<tr>
					<td></td><td><input type="hidden" name="contact" value="form"/><input type="image" src="btn-contact.gif"  width="128" height="43" alt="Отправить" class="button" id="input-submit" /></td></tr>
			</table>

		</form>
	</div>
<?php
	}
?>

</div></div></div>
<div class="col2">
	<div class='region_news'>

<?php
	include "form.txt";
?>
	</div><!-- #col2 -->
</div><!-- #region_news -->
<?php

include "bottom.php";

?>
