[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: Помогите нубу. добавить прикрепление файла к форме
Aazmandius
Здравтсвуйте, господа кодеры. Не могли бы помочь? Есть скрипт для отправки писем. Требуется добавить возможность прикрепления аттачей.

<?
session_start ();
require_once ("functions.php");
$params = array('topic','author','email','emailto','message','code','valid','astext');
require_once ("params.php");
include "head.php";

$error ='';
if (empty($code) or empty($valid) or md5($code)!=$valid) {
$error.='<br>Не указан верный код сообщения';
}
if (empty($author) or empty($email) or empty($emailto)) {
$error.='<br>Не заполнены обязательные поля сообщения';
}
$message_dec = htmlspecialchars_decode($message);
$message0 = '';
if (!empty($message_dec)) {
$message0 = strip_tags ($message_dec);
$len = strlen($message0);
if ($len > MAX_MESSAGE_GB) {
$error.='<br>Превышена максимальная длина сообщения ('.$len.'). Значение из файла настроек: '.MAX_MESSAGE_GB;
}
else {
$words=split("[ \n]",$message0);
for ($i=0; $i<count($words); $i++) {
if (strlen($words[$i]) > MAX_WORD_GB) {
$error.='<br>Превышена максимальная длина слова ('.$words[$i].'). Значение из файла настроек: '.MAX_WORD_GB;
break;
}
}
}
}

$n = get_next_time (0);
if ($n!=0) {
$error.='<br>Не исчерпано время между отправкой сообщений скриптом. Попробуйте повторить через '.$n.' сек.';
}
if (!empty($error)) {
print "<p>Извините, Ваше письмо не может быть отправлено. Причины:$error</p>";
}
else {
$dt=date("d.m.Y, H:i",time());
if ($astext) {
$data = $message0."\r\nАдрес для ответа: ".$email;
$content_type = "Content-type: text/plain; charset=windows-1251\r\n";
}
else {
$data = '<html><head><title>'.$topic.'</title></head><body><p>'.$message_dec.'</p></body></html>';
$content_type = "Content-type: text/html; charset=windows-1251\r\n";
}
if (empty($topic)) $topic='Без темы';
$result = mail ("$emailto","$topic","$data",
"From: $author <$email>\r\n"
."To: $emailto\r\n"
."Subject: $topic\r\n"
."Reply-To: $email\r\n"
.$content_type
."X-Mailer: PHP/" .phpversion()."\r\n\r\n");
if ($result) {
get_next_time (1);
print "<p>Спасибо, Ваше сообщение успешно отправлено на указанный адрес.</p>";
}
else {
print "<p>Не удалось отправить сообщение. Проверьте настройки почтового сервера</p>";
}
}


include "index2.php";
include "foot.php";
?>



<form name="f1" method="post" action="post.php">
<table
border="0" cellpadding="0" cellspacing="0" width="80%" class="n">
<tr><td><p>
Тема письма:</p></td><td><p><input type="text" name="topic" size="80" maxlength="80" value="<? print htmlspecialchars(magic($topic)); ?>"></p></td></tr>
<tr><td><p><font
color="red">Имя отправителя</font>:</p></td><td><p><input type="text" name="author" size="80" maxlength="80" value="<? print htmlspecialchars(magic($author)); ?>"></p></td></tr>
<tr><td><p><font
color="red">E-mail отправителя</font>:</p></td><td><p><input type="text" name="email" size="80" maxlength="80" value="<? print htmlspecialchars(magic($email)); ?>"></p></td></tr>
<tr><td><p><font
color="red">E-mail получателя</font>:</p></td><td><p><input type="text" name="emailto" size="80" maxlength="80" value="<? print htmlspecialchars(magic($emailto)); ?>"></p></td></tr>
<?
generate_code(); ?>
</table>
<textarea
id="elm1" name="message" rows="15" cols="80" style="width: 80%"><? print "$message"; ?></textarea>
<p><input
type="submit" name="save" value="Отправить" onclick="return checkmail();">
<input
type="reset" name="reset" value="Сброс">
<input
type="checkbox" name="astext" value="1" <? print ($astext>0?" checked":""); ?>>Как простой текст
</p>
</form>

Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.