Новичок
Покинул форум
Сообщений всего: 4
Дата рег-ции: Дек. 2015
Помог: 0 раз(а)
|
<?php
$host="localhost";
$user="root";
$pass=""; //установленный вами пароль
$db_name="gkhn";
$link=mysql_connect($host,$user,$pass);
mysql_select_db($db_name,$link);
?>
<form action="" method="POST" onSubmit = "return checkform(this)" enctype="multipart/form-data">
<br />
<br />
<div style="left:25px">
<h2 class="text-light" style = "color:#2086bf">ОСТАВИТЬ ЗАЯВКУ-ОБРАЩЕНИЕ</h2> </div>
<div style="left:25px; top:22px">
<h5 class="text-light" style = "color:#2086bf">Укажите на карте адрес проблемы или заполните вручную</h5> </div>
<br />
<div class="grid">
<div class="row cells2">
<div class="cell">
<div class="row cell">
<div class="cell">
<div id="map"></div>
</div>
</div>
</div>
<div class="cell" style="left:50px">
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong >Адрес проблемы</strong></label>
<textarea type="textarea" name="title" id = "id_2" required></textarea>
<button class="button helper-button clear"><span class="mif-cross"></span></button>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Описание проблемы</strong></label>
<textarea type="textarea" name="opispr" required></textarea>
<button class="button helper-button clear"><span class="mif-cross"></span></button>
</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Укажите категорию обращения</strong></label>
<div class="input-control select info" style = "width:500px;">
<select name = "categ">
<option VALUE="Несанкционированные автостоянки">Несанкционированные автостоянки</option>
<option VALUE="Наличие мусора на придомовых территориях">Наличие мусора на придомовых территориях</option>
<option VALUE="Нарушения в предоставлении жилищных услуг"SELECTED>Нарушения в предоставлении жилищных услуг</option>
<option VALUE="Нарушения в предоставлении коммунальных услуг">Нарушения в предоставлении коммунальных услуг</option>
<option VALUE="Нарушения в квитанциях на оплату">Нарушения в квитанциях на оплату</option>
</select>
</div>
</div>
<br />
<br />
<br />
<div class="input-control text file info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Загрузить файл (не более 2 мб)</strong></label>
<input type="file" name= "imgupload" required >
<button class="button"><span class="mif-folder"></span></button>
</div>
<br />
<br />
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Введите e-mail</strong></label>
<input type="text" name="email" required>
<button class="button helper-button clear"><span class="mif-cross"></span></button>
</div>
<br />
<br />
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Введите номер телефона</strong></label>
<input type="text" name="tel" required>
<button class="button helper-button clear"><span class="mif-cross"></span></button>
</div>
<br />
<br />
<br />
<div class="input-control text info" style = "width:500px;" data-role="input">
<label style = "color:#2086bf"><strong>Хотите ли Вы участвовать</strong></label>
<div>
<label style = "color:#2086bf"><strong>в контрольных мероприятиях</strong></label>
</div>
<div class="input-control select info" style = "width:500px;">
<select name = "fartov">
<option VALUE="Нет" SELECTED>Нет</option>
<option VALUE="Да">Да</option>
</select>
</div>
</div>
<div class="form-actions">
<br />
<br />
<input type="submit" name = "go" value="Отправить данные" class="button primary" style = "width:500px;">
</div>
</div>
</div>
</form>
<?php
//обработка ошибок
error_reporting(0);
ini_set('display_errors', 0);
//считаем количество строк в базе и присваиваем номер заявке
$c = mysql_query("SELECT COUNT('id') FROM pages ");
$d = mysql_fetch_array( $c );
if(!empty($_POST['go'])){
$date1 = date("Y-m-d");
$date2 = date("d.m.Y");
$title=$_POST['title'];
$tel=$_POST['tel'];
$email=$_POST['email'];
$opispr=$_POST['opispr'];
$fartov=$_POST['fartov'];
$categ=$_POST['categ'];
if (isset($_POST['description']))
$description = $_POST['description'];
if ($description == '')
unset($description);}
}
if (empty($_FILES['imgupload']['name']))
{
$ver = 0;
}
else
{
$path_directory = 'imagezog/';
$ver = 1;
//папка, куда будет загружаться начальная картинка и ее сжатая копия
if(preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)|(gif)|(GIF)|(png)|(PNG)$/',$_FILES['imgupload']['name']))
//проверка формата исходного изображения
{
$filename = $_FILES['imgupload']['name'];
$source = $_FILES['imgupload']['tmp_name'];
$target = $path_directory . $filename;
move_uploaded_file($source, $target);
//загрузка оригинала в папку $path_directory
if(preg_match('/[.](GIF)|(gif)$/', $filename)) {
$im = imagecreatefromgif($path_directory.$filename) ;
//если оригинал был в формате gif, то создаем изображение в этом же формате. Необходимо для последующего сжатия
}
if(preg_match('/[.](PNG)|(png)$/', $filename)) {
$im = imagecreatefrompng($path_directory.$filename) ;
//если оригинал был в формате png, то создаем изображение в этом же формате. Необходимо для последующего сжатия
}
if(preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)$/', $filename)) {
$im = imagecreatefromjpeg($path_directory.$filename);
}
$w = 500;
$w_src = imagesx($im);
$h_src = imagesy($im);
$dest = imagecreatetruecolor($w,$w);
if ($w_src>$h_src)
imagecopyresampled($dest, $im, 0, 0,
round((max($w_src,$h_src)-min($w_src,$h_src))/2),
0, $w, $w, min($w_src,$h_src), min($w_src,$h_src));
if ($w_src < $h_src)
imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w,
min($w_src,$h_src), min($w_src,$h_src));
if ($w_src==$h_src)
imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, $w_src, $w_src);
$date=time();
imagejpeg($dest, $path_directory.$date.".jpg");
$content = $path_directory.$date.".jpg";
$delfull = $path_directory.$filename;
unlink ($delfull);
}
else
{
echo '';
die();
}
}
$result = mysql_query ("INSERT INTO pages(content,Dataobr,title,opispr,tel,email,otcresh,stadvip,categ,fartov) VALUES ('$content','$date1','$title','$opispr','$tel','$email','В процессе','В процессе','$categ','$fartov')");
include "tes.php";
}
?>
<script>
function checkform(f) {
var errMSG = "";
// цикл ниже перебирает все элементы в объекте f,
// переданном в качестве параметра
// функции, в данном случае - наша форма.
for (var i = 0; i<f.elements.length; i++)
// если текущий элемент имеет атрибут required
// т.е. обязательный для заполнения
if (null!=f.elements[i].getAttribute("required"))
// проверяем, заполнен ли он в форме
if (isEmpty(f.elements[i].value)) // пустой
errMSG += " " + f.elements[i].name + "\\n"; // формируем сообщение
// об ошибке, перечисляя
// незаполненные поля
// если сообщение об ошибке не пусто,
// выводим его, и возвращаем false
if ("" != errMSG) {
alert("Не заполнены обязательные поля:\\n" + errMSG);
return false;
}
}
</script>
<script>
function v()
{
if (confirm("Вы действительно хотите удалить запись?"))
{
location.href="delete.php?id=";
}
}
</script>
<script>
function showDialog(id){
var dialog = $("#"+id).data('dialog');
if (!dialog.element.data('opened')) {
dialog.open();
} else {
dialog.close();
}
}
</script>
|