Pascal Lattreuter
Grünschnabel
Hallo.
Habe folgendes Mail-Formular, welches ich um einen Dateianhang erweitern will. Weiß aber nich wie sowas geht:
Hab noch einen Code eines anderen Formulars MIT Anhangsfunktion, vielleicht kann mir das jemand zusammenfügen?
Habe folgendes Mail-Formular, welches ich um einen Dateianhang erweitern will. Weiß aber nich wie sowas geht:
PHP:
<?php
echo ('
<form action="auftragsanfrage.php?action=send" method="post">
<table border="0" width="100%" cellspacing="0" cellpadding="7">
<tr bgcolor="#79a3cb" style="color:white;">
<td colspan="2" height="23" style="padding:0px;padding-left:5px;"><b>Auftragsanfrage</b> (alle Felder mit * MÜSSEN ausgefüllt werden)</td>
</tr>
<tr bgcolor="#edf2f6">
<td width="25%">Empfänger:</td><td><select name="mailto" size="1">
<option value="info@lattreuter.de">info@lattreuter.de</option>
</select></td>
</tr>
<tr>
<td>Vorname: *</td><td><input class="a" type="text" name="vname" size="20" maxlength="999"></td>
</tr>
<tr bgcolor="#edf2f6">
<td>Nachname: *</td><td><input class="a" type="text" name="nname" size="20" maxlength="999"></td>
</tr>
<tr>
<td>Firma:</td><td><input class="a" type="text" name="firma" size="20" maxlength="999"></td>
</tr>
<tr bgcolor="#edf2f6">
<td>Straße, Nr.:</td><td><input class="a" type="text" name="strasse" size="20" maxlength="999"></td>
</tr>
<tr>
<td>PLZ, Ort:</td><td><input class="a" type="text" name="ort" size="20" maxlength="999"></td>
</tr>
<tr bgcolor="#edf2f6">
<td>Telefon:</td><td><input class="a" type="text" name="telefon" size="20" maxlength="999"></td>
</tr>
<tr>
<td>Telefax:</td><td><input class="a" type="text" name="telefax" size="20" maxlength="999"></td>
</tr>
<tr bgcolor="#edf2f6">
<td>E-Mail: *</td><td><input class="a" type="text" name="mailfrom" size="20" maxlength="999"></td>
</tr>
<tr>
<td>Anfrage: *</td><td><textarea style="font-family:Verdana; font-size:13px;" cols=20 rows=10 name="anfrage"></textarea></td>
</tr>
<tr bgcolor="#edf2f6">
<td></td><td><input value="Formular senden" type="submit"> <input value="Verwerfen" type="reset"></td>
</tr>
</table><br>
</form>
');
if ($action == "send") {
// mail-message Anfang
$message = "Ein Benutzer der Homepage www.lattreuter.de hat Ihnen eine E-Mail über das Kontaktformular gesendet. In diesem gab er folgende Daten ein:
Vorname: $vname
Nachname: $nname
Firma: $firma
Straße, Nr.: $strasse
PLZ, Ort: $ort
Telefon: $telefon
Telefax: $telefax
E-Mail-Adresse: $mailfrom
Anfrage: $anfrage
";
// mail-message Ende
// mail verschicken
mail($mailto,
"Anfrage von $mailfrom",
$message,
"CC:\nFrom: $mailfrom\nReply-To: $mailfrom\nX-Mailer: PHP/" . phpversion()
);
// Danke sagen
echo('
<CENTER>Vielen Dank für Ihre E-Mail.
<br>Wir werden Ihnen schnellstens antworten.</font>
<form><input type="button" value="Zurück" onClick="history.go(-2)"></form>
</CENTER>
');
} // $action == "send"
?>
Hab noch einen Code eines anderen Formulars MIT Anhangsfunktion, vielleicht kann mir das jemand zusammenfügen?
Code:
<? echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<? $version = substr($_SERVER['SCRIPT_NAME'],15,strlen(strpos($_SERVER['SCRIPT_NAME'],'.'))-6); ?>
<title>PHP Mail Formular <?=$version;?></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<style type="text/css" media="all">
<!--
div,p,select,input{font:100% Courier New,sans-serif; text-align:left;}
textarea,select,input{border:1px #456 outset; font-weight:bold; background:#def;}
textarea{min-width:400px; width:100%;}
.a{width:90%; margin:0 5%;}
.l{width:100%;}
.left{width:65%; float:left; white-space:nowrap;}
.leftt{width:65%; float:left; white-space:nowrap; color:#789;}
.right{width:31%; float:right; color:#789;}
.rightt{width:31%; float:right;}
.righttt{width:31%; float:right; color:#789;}
.s{min-width:50px; width:20%;}
.ss{min-width:50px; width:20%; color:#789;}
.ml{margin-left:20%; font-weight:normal;}
.nowrap{white-space:nowrap;}
.center{text-align:center; font-weight:normal;}
.reset{color:#789; text-align:center;}
.lh{line-height:3px; font-weight:normal;}
.info{font-weight:bold; font-size:100%; color:#f00; text-align:center;}
-->
</style>
<body>
<?
if(isset($senden))
{
/* Anzahl ist nicht ausgefüllt oder < 1 */
if($anzahl<1)
{
echo " <p class=\"info\">Error: Bitte im Feld Anzahl mindestens eine 1 eingeben.</p>\n </body>\n</html>";
exit;
}
/* Es wurde kein Empfänger eingegeben */
if(empty($empfaenger))
{
echo " <p class=\"info\">Error: Bitte mindestens einen Empfänger eingeben.</p>\n </body>\n</html>";
exit;
}
/* Empfänger existiert nicht */
$host_empfaenger = substr(strstr($empfaenger, '@'), 1);
if(empty($host_empfaenger))
{
echo " <p class=\"info\">Error: Dieser Empfänger existiert nicht.</p>\n </body>\n</html>";
exit;
}
/* PROBLEM mehrere Empfänger - info@php-mail-form.com */
/* Bsp: Error: Der Empfänger "tobsn.com>" "tobsn.com,mail@tobiashenze.de,mail@bumsbar.com" existiert nicht.
if(checkdnsrr($host_empfaenger) == FALSE)
{
echo " <p class=\"info\">Error: Der Empfänger "$host_empfaenger" existiert nicht.</p>\n </body>\n</html>";
exit;
}
*/
/* Betreff */
$betreff = utf8_decode($betreff);
/* Wichtigkeit */
if($priority == "high")
{$wichtigkeit = "X-Priority: 1 (Highest)\n" . "Importance: High\n";}
if($priority == "low")
{$wichtigkeit = "X-Priority: 5 (Lowest)\n" . "Importance: Low\n";}
/* Absender */
if(!empty($absender))
{
$from = "From: $absender\n";
}
/* Kopie */
if(!empty($cc))
{
$cc = "Cc: $cc\n";
}
/* Blind-Kopie */
if(!empty($bcc))
{
$bcc = "Bcc: $bcc\n";
}
/* Antworten senden an */
if(!empty($reply))
{
$reply = "Reply-To: $reply\n";
}
else
{
$reply = "Reply-To: $absender\n";
}
/* Anhang */
/* Wenn eine Datei als Anhang ausgewaehlt wurde */
if(!empty($datei))
{
/* Lese die temporaere Datei, die der Benutzer hochgeladen hat aus */
$datei_content = fread(fopen($datei,"r"),filesize($datei));
/* Codiere Datei ins BASE64-Format */
$datei_content = chunk_split(base64_encode($datei_content));
/* Generiere einen Boundary */
$boundary = strtoupper(md5(uniqid(time())));
/* Beginne den Mail-Header mit MIME-Mail-Header */
$mail_header = "Content-Type: multipart/mixed; boundary=$boundary\n";
/* Hier faengt der normale Mail-Text an */
$mail_header .= "--$boundary\n";
/* Format - (html o. txt) */
if($content_type == "text")
{
$mail_header .= "Content-Type: text/plain\n";
$mail_header .= "Content-Transfer-Encoding: 7bit\n\n";
$msg = str_replace(chr(10),"",$msg);
$msg = utf8_decode($msg);
}
else
{
$mail_header .= "Content-Type: text/html\n";
$mail_header .= "Content-Transfer-Encoding: 8bit\n\n";
}
$mail_header .= "$msg\n\n";
/* Hier faengt der Datei-Anhang an */
$datei_name = utf8_decode($datei_name);
$mail_header .= "--$boundary\n";
$mail_header .= "Content-Type: application/octetstream; name=\"$datei_name\"\n";
/* Codierung immer BASE64 */
$mail_header .= "Content-Transfer-Encoding: base64\n";
$mail_header .= "Content-Disposition: attachment; filename=\"$datei_name\"\n\n";
$mail_header .= "$datei_content\n";
/* Gibt das Ende der eMail aus */
$mail_header .= "--$boundary--\n";
}
else
{
/* Format - (html o. txt) */
if($content_type == "text")
{
$content_type = "Content-Type: text/plain\n";
$encoding = "Content-Transfer-Encoding: 7bit\n";
$msg = str_replace(chr(10),"",$msg);
$msg = utf8_decode($msg);
}
if($content_type == "html")
{
$content_type = "Content-Type: text/html\n";
$encoding = "Content-Transfer-Encoding: 8bit\n";
}
}
$i = 0;
while ($i<$anzahl)
{
$header = "MIME-Version: 1.0\n"
. $from
. $reply
. $cc
. $bcc
. $mail_header
. $content_type
. $encoding
. $wichtigkeit;
mail($empfaenger,$betreff,$msg,$header);
$k = $i+1;
print "Sende E-Mail #$k<br />";
$i++;
}
if($k > 1)
{$s = "$k E-Mails";}
else
{$s = "Eine E-Mail";}
echo "<br />$s erfolgreich versandt!";
};
?>
<div class="a">
<form enctype="multipart/form-data" method="post" action="<?$PHP_SELF?>">
<div><label for="anzahl">Anzahl:</label></div>
<div class="left">
<input id="anzahl" value="1" class="ss" name="anzahl" readonly tabindex="1" >
<select class="ml" name="priority" tabindex="2">
<option value="high">Wichtigkeit: Hoch</option>
<option selected>Wichtigkeit: Normal</option>
<option value="low">Wichtigkeit: Niedrig</option>
</select>
</div>
<div class="right">
<select class="lh" name="content_type" tabindex="3">
<option value="text" selected>Format: Text</option>
<option value="html">Format: HTML</option>
</select>
</div>
<div class="left"><label for="absender">Absender: *</label></div>
<div class="rightt"><label for="reply">Ihre Adresse: *</label></div>
<div><input id="absender" value="Trainer Max Mustermann" class="left" name="absender" tabindex="4" ></div>
<div><input id="reply" class="rightt" value="IHRE E-MAIL ADRESSE" name="reply" tabindex="5" ><label for="empfaenger">Empfänger:</label></div>
<div class="rightt"><label for="cc">Kopie:</label></div>
<div><input readonly id="empfaenger" class="leftt" value="simontamm@web.de" name="empfaenger" tabindex="6" ></div>
<div><input id="cc" class="righttt" readonly name="cc" value="info@lattreuter.silver-boards.com" tabindex="7" ></div>
<div class="left"><label for="betreff">Betreff: *</label></div>
<div class="right"><label for="bcc"> </label></div>
<div><input name="betreff" value="Fehlermeldung auf der Seite der -Jugend" class="left" tabindex="8" betreff="YES">
</div>
<div><input id="bcc" type="hidden" class="right" name="bcc" tabindex="9" ></div>
<p>
<label for="msg">Text: *</label><br><textarea cols=60 rows=9 name="msg" id="msg" tabindex="10">
Ich habe folgende Fehler auf der Seite der ?-Jugend gefunden:
</textarea>
</p>
<div class="left">
<label for="anhang">Anhang: (*)</label><br>
<input style="WIDTH: 530px" id="anhang" type="file" size="63" name="datei" tabindex="11">
</div>
<div class="right">
<label for="senden">E-Mail:</label><br>
<input id="senden" class="center" type="submit" value="Senden" name="senden" tabindex="12" ><input class="reset" type="reset" value="Löschen" tabindex="13" >
</form>
</div></DIV>
</body>
</html>