<?php
ini_set('error_reporting', E_ERROR);
ini_set('display_errors', 'Off');
?>
<?php
session_start();
require_once("config.php");

if ($_POST['act']== "y") {
	if (isset($_POST['posName']) && $_POST['posName'] == ""){
		$statusError = "$errors_name";
	} /*elseif (isset($_POST['posEmail']) && $_POST['posEmail'] == "") {
		$statusError = "$errors_mailfrom";
	} elseif(isset($_POST['posEmail']) && !preg_match("/^([a-z,._,0-9])+@([a-z,._,0-9])+(.([a-z])+)+$/", $_POST['posEmail'])) {
		$statusError = "$errors_incorrect";
		unset($_POST['posEmail']);
	}*/ elseif (isset($_POST['posRegard']) && $_POST['posRegard'] == "") {
		$statusError = "$errors_subject";
	} elseif (isset($_POST['posText']) && $_POST['posText'] == "") {
		$statusError = "$errors_message";
	} /*elseif (isset($_POST['posVIN']) && $_POST['posVIN'] == "") {
		$statusError = "$errors_message";
	}*/ elseif ($_POST['capcha'] != $_SESSION['capcha']) {
		$statusError = "$captcha_error";
	}elseif (!empty($_POST)) {
		$headers  = "MIME-Version: 1.0\r\n";
		$headers .= "Content-Type: $content  charset=utf-8\r\n";
		$headers .= "Date: ".date("Y-m-d (H:i:s)",time())."\r\n";
		$headers .= "From: Мб140 <robot@mb140.ru>\r\n";
		$headers .= "X-Mailer: My Send E-mail\r\n";

		mail("$mailto","$subject","$message","$headers");

		unset($name, $posText, $mailto, $subject, $posRegard, $message);

		$statusSuccess = "$send";
	}
}

?>
<!doctype html>
<html>
<head>
<title>Отправить сообщение</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<link href="styling.css" rel="stylesheet" type="text/css" media='screen,projection' />
</head>
<body>

<h2>Перезвоните мне</h2>
<p id="emailSuccess">
<strong style="color:green;"><?php echo "$statusSuccess" ?></strong>
</p>
<p id="emailError"><strong style="color:red;"><?php echo "$statusError" ?></strong></p>

<div id="contactFormArea">
<form action="./" method="post" id="cForm">
<input type="hidden" name="act" value="y" />
<fieldset>
<label for="posName"><b>Ваше имя:</b></label>
<input class="text" type="text" size="25" name="posName" id="posName" />
<label for="posRegard" style="margin-top: 15px;"><b>Номер телефона:</b></label>
<input class="text" type="text" size="25" name="posRegard" id="posRegard" />
<table style="margin-top: 15px;"><tr><td>
Проверочный код</td><td style="text-align: center;"><img style="border: 1px solid gray; background: url('/bg_capcha.png');
" src="captcha.php" width="120" height="40"></td></tr>
<tr><td style="margin-top: 15px;">
Введите код сюда - </td><td><input class="text" type="text" name="capcha" style="width: 142px;"></td></tr></table>
<br><br><label style="width: 95px; margin: 0 auto 15px auto;"><input class="submit" type="submit" name="selfCC" id="selfCC" value=" Отправить " /></label>
</fieldset>

</form>
</div>

</body>
</html>
