<h1>Kontakt</h1>
<img class="rechts" src="img/foto.jpg" alt="Florian Huber"/>
<h2>Florian Huber</h2>
<p>Weststraße 21<br/>
    87561 Oberstdorf<br/>
</p>
<table>
    <colgroup>
        <col width="50px" align="left">
        <col width="200px" align="left">
    </colgroup>
    <tr>
        <td>Tel:</td>
        <td>+49 8322 9408148</td>
    </tr>
    <tr>
        <td>Mobil:</td>
        <td>+49 173 3219100</td>
    </tr>
</table>


<p>E-Mail an diesen Kontakt senden</p>
<?php

error_reporting(0);

// *** Deine Mailadresse (Empf�nger) ***
$mail_to = "huber-putz@gmx.net";
// *************************************

$from_name = $_POST['fromname'];
$from_mail = strtolower($_POST['frommail']);
$mail_subject = $_POST['mailsubject'];
$mail_text = $_POST['mailtext'];
$send = $_POST['s'];
$err_text = [];

if (trim($from_name) == "") {
    $err_text[] = "Bitte den Namen angeben!";
}
if (trim($from_mail) == "") {
    $err_text[] = "Bitte die E-Mail-Adresse angeben!";
} else {
    if (!filter_var($from_mail, FILTER_VALIDATE_EMAIL)) {
        $err_text[] = "Bitte eine gültige E-Mail-Adresse angeben.";
    }
}
if (trim($mail_subject) == "") {
    $err_text[] = "Bitte einen Betreff eingeben.";
}
if (trim($mail_text) == "") {
    $err_text[] = "Bitte einen Nachrichtentext eingeben.";
}

// *** Zu langen Text abschneiden ***
if (strlen($mail_text) > 1000) {
    $mail_text = substr($mail_text, 0, 1000) . "... (Text wurde gekürzt!)";
}
$from_name = str_replace(chr(34), "''", $from_name);
$mail_subject = str_replace(chr(34), "''", $mail_subject);
$from_name = stripslashes($from_name);
$from_mail = stripslashes($from_mail);
$mail_subject = stripslashes($mail_subject);
$mail_text = stripslashes($mail_text);

if (($send == "1") && (count($err_text) > 0)) {
    echo "<p><b>Fehler:</b><br/>";
    echo implode('<br/>', $err_text) . "</p>";
}

if (($send != "1") || (count($err_text) > 0)) {
    ?>

    <form action="index.php?section=kontakt" method="post">
        <label for="fromname">Name:</label><br/>
        <input type="text" name="fromname" id="fromname" size=50 maxlength=120 value="<?php
        echo $from_name; ?>"/><br/>
        <label for="frommail">E-Mail Adresse:</label><br/>
        <input type="text" name="frommail" id="frommail" size=50 maxlength=120 value="<?php
        echo $from_mail; ?>"/><br/>
        <label for="mailsubject">Betreff:</label><br/>
        <input type="text" name="mailsubject" id="mailsubject" size=50 maxlength=120 value="<?php
        echo $mail_subject; ?>"/><br/>
        <label for="mailtext">Text: <i>(max. 1000 Zeichen)</i></label><br/>
        <textarea cols="40" rows="10" name="mailtext" id="mailtext"><?php
            echo $mail_text; ?></textarea>
        <input type="hidden" value="1" name="s"><br/>
        <input type="submit" value="Nachricht senden" name="submit"/>
    </form>

    <?php
} else {
    $header = "From: $from_name <$from_mail>\n";
    $header .= "Reply-To: $from_mail\n";
    $header .= "Mailer: PHP-FormMailer (www.huber-putz.com)\n";
    $header .= "Content-Type: text/plain";
    $mail_date = gmdate("D, d M Y H:i:s") . " +0000";
    $send = 0;
    if (@mail($mail_to, $mail_subject, $mail_text, $header)) {
        echo "<p><b>Die E-Mail wurde abgesendet.</b></p>";
        echo "<p><a href=\"index.php?section=kontakt&from_name=$from_name&from_mail=$from_mail\">Zurück zum Formular</a></p>";
    } else {
        echo "<p><b>Beim Versenden der E-Mail ist ein Fehler aufgetreten!</b></p>";
        echo "<p><a href=\"" . $_SERVER['PHP_SELF'] . "?from_name=$from_name&from_mail=$from_mail&mail_subject=$mail_subject&mail_text=";
        echo urlencode($mail_text) . "\">Zurück zum Formular</a></p>";
    }
}
?>


