First refactoring to PHP 8.1
This commit is contained in:
134
kontakt.php
134
kontakt.php
@@ -1,8 +1,9 @@
|
||||
<h1>Kontakt</h1>
|
||||
<img class="rechts" src="img/foto.jpg" alt="Florian Huber">
|
||||
<img class="rechts" src="img/foto.jpg" alt="Florian Huber"/>
|
||||
<h2>Florian Huber</h2>
|
||||
<p>Weststraße 21<br>
|
||||
87561 Oberstdorf<br></p>
|
||||
<p>Weststraße 21<br/>
|
||||
87561 Oberstdorf<br/>
|
||||
</p>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col width="50px" align="left">
|
||||
@@ -24,77 +25,86 @@
|
||||
|
||||
error_reporting(0);
|
||||
|
||||
// *** Deine Mailadresse (Empfänger) ***
|
||||
$mail_to="huber-putz@gmx.net";
|
||||
// *** Deine Mailadresse (Empf<EFBFBD>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'];
|
||||
$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!<br>";
|
||||
if(trim($from_mail)=="")
|
||||
$err_text.="Bitte die E-Mail-Adresse angeben!<br>";
|
||||
else
|
||||
if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$",$from_mail))
|
||||
$err_text.="Bitte eine gültige E-Mail-Adresse angeben.<br>";
|
||||
if(trim($mail_subject)=="") $err_text.="Bitte einen Betreff eingeben.<br>";
|
||||
if(trim($mail_text)=="") $err_text.="Bitte einen Nachrichtentext eingeben.<br>";
|
||||
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!)";
|
||||
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);
|
||||
$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") && (isset($err_text))) {
|
||||
echo "<p><big><b>Fehler:</b></big><br>";
|
||||
echo "$err_text</p>";
|
||||
if (($send == "1") && (count($err_text) > 0)) {
|
||||
echo "<p><b>Fehler:</b><br/>";
|
||||
echo implode('<br/>', $err_text) . "</p>";
|
||||
}
|
||||
|
||||
if(($send!="1") || (isset($err_text)))
|
||||
{
|
||||
?>
|
||||
if (($send != "1") || (count($err_text) > 0)) {
|
||||
?>
|
||||
|
||||
<form action="<?php echo "index.php?section=kontakt"; ?>" method="post">
|
||||
Name:<br>
|
||||
<input type="text" name="fromname" size=50 maxlength=120 value="<?php echo $from_name; ?>"><br>
|
||||
E-Mail Adresse:<br>
|
||||
<input type="text" name="frommail" size=50 maxlength=120 value="<?php echo $from_mail; ?>"><br>
|
||||
Betreff:<br>
|
||||
<input type="text" name="mailsubject" size=50 maxlength=120 value="<?php echo $mail_subject; ?>"><br>
|
||||
Text: <i>(max. 1000 Zeichen)</i><br>
|
||||
<td width=100%><textarea cols="40" rows="10" name="mailtext"><?php echo $mail_text; ?></textarea></td></tr>
|
||||
<input type="hidden" value="1" name="s"><br>
|
||||
<input type="submit" value="Nachricht senden" name="submit">
|
||||
</td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<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
|
||||
<?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>";
|
||||
}
|
||||
$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>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user