Ralf: kantakt-formular

Beitrag lesen

Versuch es mal mit dem unten stehenden Quellcode. Wenn ein Besucher vergisst eine Eingabe zu machen, so wird er darauf hingewiesen. Das Script ist voll funktionsfähig es ist in PHP geschrieben darum Mus auf deinen Webserver PHP ab Version 4 laufen. Zudem musst du noch die Zeile <input type=hidden name=ToMail value=e-mail@adresse.de> mit deiner Mail Adresse versehen. Die beiden anderen Zeilen kannst du ändern wie du möchtest es handelt sich dabei um dem Formular titel $body="<html><head><title>Schreiben Sie uns!</title></head>

<title>Schreiben Sie uns!</title>

<?php $body="<html><head><title>Schreiben Sie uns!</title></head><body bgcolor=#FFFFFF Link=#FF0080 ALink=#FFFFFF VLink=#400040 >"; if ($_POST[ToMail]=="") {

echo("<html><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Schreiben Sie uns!</title> </head> <body bgcolor=#FFFFFF Link=#FF0080 ALink=#FFFFFF VLink=#400040 >

<style type="text/css"> <!-- .PS_2{ top:459px; width:100px; height:30px; border-width:1px; font-size:8pt; border-color:#000000; color:#000000; background-color:#C0C0C0; border-style:solid; font-weight:; font-family:Verdana; cursor:pointer; font-style:;

} .PC_2{ top:459px; width:100px; height:30px; border-width:1px; font-size:8pt; border-color:#0000FF; color:#0000FF; background-color:#C0C0C0; border-style:solid; font-weight:; font-family:Verdana; cursor:pointer; font-style:;

} .TED1_2{ top:140px; width:200px; height:22px; border-width:1px; font-size:10pt; border-color:#0000FF; color:#0000FF; background-color:#80FFFF; border-style:solid; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TED2_2{ top:180px; width:200px; height:22px; border-width:1px; font-size:10pt; border-color:#0000FF; color:#0000FF; background-color:#80FFFF; border-style:solid; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TED3_2{ top:220px; width:200px; height:22px; border-width:1px; font-size:10pt; border-color:#0000FF; color:#0000FF; background-color:#80FFFF; border-style:solid; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TME4_2{ top:319px; width:308px; height:128px; border-width:1px; font-size:10pt; border-color:#0000FF; color:#0000FF; background-color:#80FFFF; border-style:solid; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE5_2{ top:139px; width:80px; height:20px; border-width:0px; font-size:10pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE6_2{ top:179px; width:80px; height:20px; border-width:0px; font-size:10pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE7_2{ top:219px; width:90px; height:20px; border-width:0px; font-size:10pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE8_2{ top:279px; width:100px; height:20px; border-width:0px; font-size:10pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE9_2{ top:49px; width:310px; height:50px; border-width:0px; font-size:28pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TTE10_2{ top:99px; width:520px; height:30px; border-width:0px; font-size:10pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TMT11_2{ top:140px; width:170px; height:190px; border-width:0px; font-size:10pt; border-color:#808080; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} .TCH12_2{ top:430px; width:15px; height:15px; border-width:0px; font-size:10pt; border-color:#C0C0C0; color:#0000FF; background-color:#C0C0C0; border-style:solid; font-weight:; font-family:MS Sans Serif; cursor:text; font-style:;

} .TTE13_2{ top:429px; width:152px; height:15px; border-width:0px; font-size:8pt; border-color:#000000; color:#0000A0; background-color:#FFFFFF; border-style:none; font-weight:; font-family:Verdana; cursor:text; font-style:;

} --></style>

<script language=javascript> function check_form() { var error,i,set,str,ele,elenam,zeichen; ele=3; elenam='Name';

set='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZß '; str=window.document.forms[0].elements[ele].value; if (str.length<1) { alert('Bitte machen Sie eine Eingabe in Element '+elenam); return false; }

ele=5; elenam='Message';

set='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZß '; str=window.document.forms[0].elements[ele].value; if (str.length<1) { alert('Bitte machen Sie eine Eingabe in Element '+elenam); return false; }

ele=6; elenam='Kommentar';

set='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZß '; str=window.document.forms[0].elements[ele].value; if (str.length<1) { alert('Bitte machen Sie eine Eingabe in Element '+elenam); return false; }

} </script>

<form action=kontaktform.php method=post> <input type=hidden name=ToMail value=e-mail@adresse.de> <DIV ID=EL1 style="position:absolute; left:229px;top:459px;z-index:1"> <input class=PS_2 type=Submit value=Senden onclick="return check_form()"> </DIV> <DIV ID=EL2 style="position:absolute; left:19px;top:459px;z-index:2"> <input class=PC_2 type=Reset value=Reset> </DIV> <DIV ID=EL3 style="position:absolute; left:130px;top:140px;z-index:3"> <input class=TED1_2 type=text name=Name value=> </DIV> <DIV ID=EL4 style="position:absolute; left:130px;top:180px;z-index:4"> <input class=TED2_2 type=text name=E-Mail_Absender value=> </DIV> <DIV ID=EL5 style="position:absolute; left:130px;top:220px;z-index:5"> <input class=TED3_2 type=text name=Message value=> </DIV> <DIV ID=EL6 style="position:absolute; left:19px;top:319px;z-index:6"> <textarea class=TME4_2 name=Kommentar></textarea> </DIV> <DIV ID=EL7 style="position:absolute; left:19px;top:139px;z-index:7"> <font class=TTE5_2>Ihr Name</font> </DIV> <DIV ID=EL8 style="position:absolute; left:19px;top:179px;z-index:8"> <font class=TTE6_2>E-Mail</font> </DIV> <DIV ID=EL9 style="position:absolute; left:19px;top:219px;z-index:9"> <font class=TTE7_2>Überschrift</font> </DIV> <DIV ID=EL10 style="position:absolute; left:19px;top:279px;z-index:10"> <font class=TTE8_2>Kommentar</font> </DIV> <DIV ID=EL11 style="position:absolute; left:17px;top:49px;z-index:11"> <font class=TTE9_2>Kontaktformular</font> </DIV> <DIV ID=EL12 style="position:absolute; left:19px;top:99px;z-index:12"> <font class=TTE10_2>___________________________________________________________</font> </DIV> <DIV ID=EL13 style="position:absolute; left:350px;top:140px;z-index:13"> <table  class=TMT11_2> <tr><td valign=top> <span style="font-family:Verdana;font-size:10pt;font-style:;font-weight:;color:#0000A0"> Für Ihre Anfrage oder <br>Meinung, nutzen <br>Sie bitte dieses <br>Formular!<br>&#160;<br>Vergessen Sie nicht eine<br>Kontaktadresse <br>(E-Mail oder Tel.)<br>anzugeben, wenn Sie <br>eine Antwort wünschen.<br> </span> </td></tr> </table> </DIV> <DIV ID=EL14 style="position:absolute; left:360px;top:430px;z-index:14"> <input class=TCH12_2 type=Checkbox name=Antwort value=JA> </DIV> <DIV ID=EL15 style="position:absolute; left:379px;top:429px;z-index:15"> <font class=TTE13_2>Ich bitte um Rückantwort</font> </DIV>

<input type=hidden name=FormularTitel value=Schreiben#Sie#uns!> </form></body></html>"); } else { $message=""; foreach($_POST as $key => $value) {

if (is_array($_POST[$key]))

{

$merk=$key;         $liste="";

foreach($_POST[$key] as $key => $value)                 {                      $liste="$liste\n$value";                 }         $message="$message\n\n$merk\n$liste";

} else

{         if ($key == "ToMail") {$email=$value;}         if ($key == "FormularTitel") {          $titel=str_replace("#", " ", $value);         }         $message="$message\n\n$key\n$value";         } }

echo($body); mail($email,$titel,$message,"From: <$email>"); echo("<font face=verdana size=2>Vielen Dank!  Das Formular wurde gesendet.</font>");

echo("<p><font face=verdana size=2><a href=kontaktform.php>Zurück zum Kontaktformular</a></font>"); }

?>

</body> </html>