<?php
include ("../block/bd.php");
include ("../block/grafi.php");
$result = mysql_query ("INSERT INTO `brides_data`
(`fname`, `sname`, `birth_d`, `birth_month`, `birth_yr`,
`country`, `town`, `sex`, `length`, `weight`, `alkogol`, `fuma`,
`marital_status`, `children`, `education`, `sfera_deeds`, `foreign_lang`,
`foreig_lang_level`, `hobbies`, `charakter`, `selfpresentation`, `email`,
`password`, `img_url`) VALUES ('$fname', '$sname', '$birth_d',
'$birth_month', '$birth_yr', '$country',
'$town', '$sex', '$length', '$weight', '$alkogol', '$fuma',
'$marital_status', '$children', '$education', '$sfera_deeds',
'$foreign_lang', '$foreig_lang_level', '$hobbies', '$charakter',
'$selfpresentation', '$email', '$password', '$img_url');");
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] .'/image/img_brides/';
$fieldname = 'foto_upload';
$uploadedfile = $_FILES[$fieldname]['tmp_name'];
$out = mysql_query ("SELECT id_bride FROM brides_data ORDER BY id_bride DESC",$db);
$myrow = mysql_fetch_array ($out);
$id_bride = $myrow['id_bride'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newwidth=150;
$newheight=($height/$width)*150;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$resultfile = $uploadsDirectory.$id_bride.".jpg";
//'-'.$_FILES[$fieldname]['name'];
imagejpeg($tmp,$resultfile,100);
$filename = $id_bride.".jpg";
$imgparth = mysql_query ("UPDATE `brides_data` SET `img_url` = '$filename' WHERE `id_bride` = '$id_bride';");
imagedestroy($src);
imagedestroy($tmp);
unlink($uploadedfile);
$theme = "New user";
$to = "my@mail.ru";
$message = "
<html>
<head></head>
<body>
".date("d.m.Y H:i:s")."
".$fname." ".$sname." ".$birth_yr."".$country."
".$town." ".$sex."".$selfpresentation." ".$email."
</html>
</body>
";
$message = convert_cyr_string($message, 'w', 'k');
$headers = "Content-Type: text/html; charset=KOI8-R\r\n";
//
if ($result && $imgparth == 'true')
{
echo "Ваши данные добавлены в базу данных! <br> Your data are added to base!";
mail($to, $subject, $message, $headers);
}
else
{
echo "<b>Ошибка! Обратитесь к администратору! <br>Не используйте знак одиночной кавычки ' !<br> Error! Contact administrator<br> Dont use ' !</b>";
}
exit
?>
|