• Das Erstellen neuer Accounts wurde ausgesetzt. Bei berechtigtem Interesse bitte Kontaktaufnahme über die üblichen Wege. Beste Grüße der Admin

Hilfe beim Konatkforumular

Chiller10

New member
ich habe die frage ihier gestellt weil ich mir nicht sicher war wo ich sie posten sollte

also ich habe ein Kontaktformular mit nur einer php datei aber wenn ich deine nachricht geschrieben habe und diese senden will kommt in meinem posteingang keine nachricht an und deswegen komme ich net weiter

hier der code

kontakt.php
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>Kontaktformular</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 </head>
<body>

<div style="text-align: center;">
 <h3>Kontaktformular</h3>

<?php
// Kontaktformular 1 - Homepage-Total.de

if ($_SERVER['REQUEST_METHOD'] == "POST") {
$vorname = $_POST['vorname'];
$nachname = $_POST['nachname'];
$betreff = $_POST['betreff'];
$nachricht = $_POST['nachricht'];
$email = $_POST['email'];

 # Ihre E-Mail-Adresse
 $an ="domain@domain.de";

 # Diese Nachricht wird an Ihre E-Mail-Adresse gesendet
 $text = "Hallo Administrator,\n du haben eine neue Nachricht von $vorname $nachname erhalten:\n\n
 ====\n $nachricht\n====\n\nSie können $vorname $nachname unter dieser $email erreichen.";
 @mail($an, $betreff, $text, "From: " . $email);
 echo "<b>Ihre Nachricht wurde gesendet!</b>";
}
else { ?>

<script type="text/javascript">
function eingaben_ueberpruefen(){
 var mail = document.Formular.email.value;
 if (document.Formular.vorname.value.length < 3) { // Vorname mindestens 2 Zeichen
  alert("Sie haben noch keinen Vornamen eingegeben!")
  document.Formular.vorname.focus();
  return false;
 }

 else if (document.Formular.nachname.value.length < 3) { // Nachname mindestens 2 Zeichen
  alert("Bitte geben Sie Ihren Nachnamen ein");
  document.Formular.nachname.focus();
  return false;
 }

 else if (mail.length < 10 || mail.indexOf ('@',0) == -1 || mail.indexOf ('.',0) == -1) {
  alert("Bitte geben Sie eine gültige E-Mail-Adresse ein.")
  document.Formular.email.select();
  return false;
 }

 else if (document.Formular.betreff.value.length < 10) { // Betreff mindestens 9 Zeichen
  alert("Bitte geben Sie einen Betreff ein!")
  document.Formular.betreff.focus();
  return false;
 }

 else if (document.Formular.nachricht.value.length < 20) { // Nachricht mindestens 19 Zeichen
  alert("Bitte geben Sie eine Nachricht ein!")
  document.Formular.nachricht.focus();
  return false;
 }

 else
 return true;
}
</script>

<form name="Formular" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>"
 onSubmit="return eingaben_ueberpruefen();">
 <table cellPadding="4" cellSpacing="2" border="1">
  <tr>
   <td><b>Vorname:</b></td>
   <td><input type="text" name="vorname" size="35" maxlength="40"></td>
  </tr>
  <tr>
   <td><b>Nachname:</b></td>
   <td><input type="text" name="nachname" size="35" maxlength="40"></td>
  </tr>
  <tr>
   <td><b>E-Mail:</b></td>
   <td><input type="text" name="email" size="35" maxlength="40"></td>
  </tr>
  <tr>
   <td><b>Betreff:</b></td>
   <td><input type="text" name="betreff" size="45" maxlength="60"></td>
  </tr>
  <tr>
   <td colspan="2">
    <b>Nachricht:</b><br><textarea name="nachricht" cols="45" rows="10"></textarea>
   </td>
  </tr>
  <tr>
   <th colspan="2"><br>
    <input type="submit" value="Formular absenden">
   </th>
  </tr>
 </table>
</form>

<?php
}
?>

</div>

</body>
</html>

aber bitte antwortet sie in einem gesamten code weil ich mich mit php nicht sogut auskenne
 
ich habe eben die genzezeit zeile 12 "// Kontaktformular 1 - Homepage-Total.de" übersehen ich gucke mal was ich da so finde
 
Habe grad wenig Zeit zur Fehlersuche. Deshalb habe ich Dir mal ein 100% funktionierendes Script gepostet.
Da fehlt jetzt halt die CSS-Referenz. Dafür habe ich schnell ein paar Style-Tags eingefügt. Aber das Styling des Formulars kannst Du sicher selbst leicht anpassen.
Im Übrigen werden die Felder auch noch alle auf Eingaben und teilweise sogar deren Plausibiliät überprüft.

Viel Spaß damit und wenn Du fragen hast, melde Dich einfach...

Hier das komplette Script:

PHP:
<?php
$strEmpfaenger = 'alias@domain.de'; //Hoer die E-Mail Adresse an die die Formulardaten geschickt werden sollen

$strSubject    = 'Hier den gewünschten Betreff hinschreiben';
$strReturnhtml = 'danke.html'; //hier kannst Du ein Seite aufrufen, die dem Besucher sagt, dass seine Mailmangekommen ist
$strDelimiter  = ":\t";

if($_POST)
{
$strFrom = $_POST['email'];
 $strMailtext = "";

 while(list($strName,$value) = each($_POST))
 {
//if ($strName == "email_repeat"){$strName = " ";$value = $Absender;}
  if(is_array($value))
  {
   foreach($value as $value_array)
   {
    $strMailtext .= $strName.$strDelimiter.$value_array."\n";
   }
  }
  else
  {
   $strMailtext .= $strName.$strDelimiter.$value."\n";
  }
 }

 if(get_magic_quotes_gpc())
 {
  $strMailtext = stripslashes($strMailtext);
 }

 mail($strEmpfaenger, $strSubject, $strMailtext, "From: ".$strFrom)
  or die("Die Mail konnte nicht versendet werden.");
 header("Location: $strReturnhtml");
 exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--- designed by Dipl.-Ing. Hansi Schlegel (magic-motion-pictures)  2009 --->
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <title></title>
<script language="JavaScript">
    <!--
    function chkFormular()
    {
                  
if(document.Formular.vorname.value == "")
      {
       alert("Bitte Vorname eingeben!");
       document.Formular.vorname.focus();
       return false;
      }
                  
if(document.Formular.name.value == "")
      {
       alert("Bitte Namen eingeben!");
       document.Formular.name.focus();
       return false;
      }
                  
if(document.Formular.strasse.value == "")
      {
       alert("Bite Strasse und Hausnummer eingeben!");
       document.Formular.strasse.focus();
       return false;
      }
                  
if(document.Formular.ort.value == "")
      {
       alert("Bitte PLZ und Ort eingeben!");
       document.Formular.ort.focus();
       return false;
      }

if(document.Formular.land.selectedIndex == 0)
	{
	alert("Bitte Land auswählen!");
	document.Formular.land.focus();
	return false;
	}

if(document.Formular.land.selectedIndex == 1)
	{
	alert("Bitte Land auswählen!");
	document.Formular.land.focus();
	return false;
	}

if(document.Formular.land.selectedIndex == 6)
	{
	alert("Bitte Land auswählen!");
	document.Formular.land.focus();
	return false;
	}

if(document.Formular.tel.value == "")

      {
       alert("Bitte Telefon-Nummer eingeben!");
       document.Formular.tel.focus();
       return false;
      }
 var telefon = document.Formular.tel.value
 var zeichen_ok = true
 var akt_pos = 0
 var akt_zeichen = ""
 var Ziffern ="0123456789 /+-"

 while (zeichen_ok && akt_pos < telefon.length)
 {
 akt_zeichen = telefon.charAt(akt_pos)
 zeichen_ok = (Ziffern.indexOf(akt_zeichen) != -1)
 akt_pos++
 }
 if (! zeichen_ok)
 {
 alert("Bitte nur Ziffern eingeben (auch Leerzeichen sind erlaubt)")
       document.Formular.tel.focus();
 return false
 }         
   
if(document.Formular.emaill.value == "")

      {
       alert("Bitte E-Mail Adresse eingeben!");
       document.Formular.emaill.focus();
       return false;
      }

if(document.Formular.emaill.value.indexOf('@') == -1)
      {
       alert("E-mail Adrese ungültig!");
       document.Formular.emaill.focus();
       return false;
      }

  
if(document.Formular.emaill.value.indexOf('.') == -1)
      {
       alert("E-mail Adrese ungültig!");
       document.Formular.emaill.focus();
       return false;
      }

if(document.Formular.email.value == "")

      {
       alert("Bitte E-Mail Adresse eingeben!");
       document.Formular.email.focus();
       return false;
      }

 if(document.Formular.emaill.value != document.Formular.email.value)

      {
       alert("Die Wiederholung der E-Mail Adresse stimmt nicht mit der ersten Eingabe überein!");
       document.Formular.email.focus();
       return false;
      }
      
if(document.Formular.email.value == document.Formular.emaill.value)
if(document.Formular.email.value.indexOf(' ') == -1)
      {
		document.Formular.emaill.value=" "+document.Formular.emaill.value
		document.Formular.email.value=" "+document.Formular.email.value
		document.Formular.vorname.value=" "+document.Formular.vorname.value
		document.Formular.name.value=" "+document.Formular.name.value
  		document.Formular.strasse.value=" "+document.Formular.strasse.value
		document.Formular.ort.value=" "+document.Formular.ort.value
		document.Formular.tel.value=" "+document.Formular.tel.value
		document.Formular.fax.value=" "+document.Formular.fax.value
      }

 if(document.Formular.nachricht.value == "")

      {
       alert("Schreiben Sie bitte Ihre Nachricht in das Textfeld!");
       document.Formular.nachricht.focus();
       return false;
      }
 if(document.Formular.nachricht.value == "Schreiben Sie hier Ihre Nachricht:")

      {
       alert("Schreiben Sie bitte Ihre Nachricht in das Textfeld!");
       document.Formular.nachricht.value = "";
       document.Formular.nachricht.focus();
       return false;
      }

if(document.Formular.vorname.value != "")
if(document.Formular.name.value != "")
if(document.Formular.strasse.value != "")
if(document.Formular.ort.value != "")
if(document.Formular.tel.value != "")
if(document.Formular.emaill.value != "")
if(document.Formular.email.value != "")
if(document.Formular.nachricht.value != "")
if(document.Formular.nachricht.value != "Schreiben Sie hier Ihre Nachricht:")
	{
	document.Formular.submit();
	}

  }
//-->
</script>
<script language="JavaScript">
    <!--
function ClearArea()
      {
if(document.Formular.nachricht.value != "")
if(document.Formular.nachricht.value == "Schreiben Sie hier Ihre Nachricht:")
      {
       document.Formular.nachricht.focus();
       document.Formular.nachricht.value = ""
  	}
  	}
//-->
</script>
</head>

<body>




<form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" name="Formular" onsubmit="Speichern();return chkFormular()">
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=450" class="form">

<tr VALIGN=TOP>
<td> 
</td>
<td ALIGN=RIGHT VALIGN=BASELINE ><input TYPE="hidden" NAME="Absender" value="(siehe nachstehende Angaben)" SIZE=48></td>
</tr>
<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">Vorname:<font color="#FF0000">*</font> </font></font></font></font></td>

<td ALIGN=LEFT><input TYPE="TEXT" NAME="vorname" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">Name:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT ><input TYPE="TEXT" NAME="name" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif"> Strasse und Hausnr.:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="strasse" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">PLZ und Ort:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="ort" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">Land:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  >
<select name="land" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FFFFFF;border:1px solid color:#400000;width:255px">
<option value="0" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FFFFFF;">Land auswählen</option>
<option  value="CH" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FDF4ED;"> ---------- </option>
<option  value="DE" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FFFFFF;">Deutschland</option>
<option  value="IT" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FDF4ED;">Italien</option>
<option  value="AT" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FFFFFF;">Österreich</option>
<option  value="CH" style="font-family: Verdana;font-size:11px;color:#400000;background-color:#FDF4ED;">Schweiz</option>
</select></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">Telefon:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="tel" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">Fax:   </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="fax" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">E-Mail:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="emaill" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

<tr VALIGN=TOP>
<td ALIGN=RIGHT VALIGN=BASELINE  ><p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">E-mail wiederholen:<font color="#FF0000">*</font> </font></font></font></td>

<td ALIGN=LEFT  ><input TYPE="TEXT" NAME="email" SIZE=48 style="background-color:#FFFFFF;color:#400000;font-size:10px;border:1px solid color:#400000;width:254px"></td>
</tr>

</td>
</tr>
<tr VALIGN=top align="right">
<td >
<p class="rechts" style="font-size:11px;font-family:tahoma,arial,sans-serif">
Ihre Nachricht:<font color="#FF0000">*</font> </font></font></font>
</td>
<td ALIGN=LEFT  >
<textarea NAME="nachricht" rows=5 cols=48 onFocus="ClearArea();Speichern();return false;" style="background-color:#FFFFFF;color: #400000;font-family: tahoma,arial,sans-serif;font-size: 11px;border: solid 1 px;width:254px">Schreiben Sie hier Ihre Nachricht:</textarea>

</td>

</tr>

<tr>
<td><p class="zentriert" style="font-size:12px";font-color:#004000">
<font color="#FF0000"><b>*</font> Pflichtfelder
 </b></font></font></p>
</td>
<td align="left"><p class="links" style="font-size:10px";font-color:#FFFFFF">
<input type="button" name="send" value="Mail Absenden" onclick="javascript:chkFormular(); return true;" style="cursor:hand;background-color:#C0C0C0;color:black;font-family:tahoma,arial,sans-serif;font-size:11px;width:100px;height:18px;border-color:#400000;border-width:1px;" onmouseover="this.style.backgroundColor='#FFFFFF';this.style.color='#000000';"  onmouseout="this.style.backgroundColor='#C0C0C0';this.style.color='black'" />




</td>
</tr>

</table>
</form>
</center>
</body>
</html>
 
Zurück
Oben