Hmm, ich hatte bei Module 4.8.x gesucht, weil ich dachte nur dort sinnvolle Infos zu bekommen zu können.
Danke MC für den Link. Ich habe leider das Problem dass mein Kontaktformular ja ein wenig speziell ist.
Ich kann als Fehlermeldung nicht einfach die Meldung ausgeben sondern muss das Gerüst (Kontaktdaten, Naviagtion)des Kontaktformluars dabei ausgeben lassen. Und auch weil ich bei den Textfeldern, ums smarter aussehen zu lassen, eine Hintergrundgrafik eingebaut habe die dann bei den Statusmeldungen mit einer anderen überdeckt wird. Programmiertechnisch nicht gerade schön, aber ich wusste es leider nicht anders umzusetzen

. Außerdem ist es bei mir so das ja in den Textfeldern schon etwas drin steht und daher die Validierung, ob beim klick auf senden überhaupt etwas eingegeben wurde, nicht greift. Da wäre es natürlich auch absolut sinnvoll eine Möglichkeit zur Kontrolle zu haben.
Aus den genannten Gründen weiß ich nicht wie ich die eMail-Validierung, des von MC genannten Postings, in meinen Output-Code des Formulars einbinden kann um es zum laufen zu bringen. Hier mal mein Output-Code:
Code: Alles auswählen
<?php
/**
* $RCSfile$
*
* Description: Contact Form Output
*
* @version 1.0.0
* @author Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-08-12
* modified 2008-04-11 Rudi Bieller Changes concerning new layout
* }}
*
* $Id$
*/
#Includes
cInclude("classes", "class.phpmailer.php");
if (!isset($tpl) || !is_object($tpl)) {
$tpl = new Template();
}
if (!isset ($_POST['send'])) {
#Form has not been sent yet
cInclude('classes', 'class.article.php');
cInclude('classes', 'class.template.php');
#Create contact form
$sFormAction = $sess->url("front_content.php?idcat=$idcat&idart=$idart&parentid=$parentid");
$tpl->set("s", 'form_action', $sFormAction);
$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/kontaktformular.html");
} elseif ($_POST['send'] == 1) {
#Form has been sent
#Check user input
$noerrors = true;
$msg = '';
if ($_POST['eMail'] == '') {
$noerrors = false;
#Errors have been found
echo "<div id=\"contactForm\"><table width=\"906\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >
<tr>
<td align=\"left\" valign=\"top\" width=\"36\" > </td>
<td align=\"left\" valign=\"top\" width=\"273\"><p>+49 (0) 6221 35 44 873</p><img src=\"http://www.vivaxmedia.de/upload/pics/space.gif\" border=\"0\" width=\"1\" height=\"11\" />
<p>info@vivaxmedia.de</p><img src=\"http://www.vivaxmedia.de/upload/pics/space.gif\" border=\"0\" width=\"1\" height=\"11\" />
<p>hauptstraße 63<br />
69221 dossenheim</p></td>
<td valign=\"top\" width=\"245\" height=\"130\" style=\"color:#2dbee7;\" background=\"http://www.vivaxmedia.de/upload/pics/cont.gif\" border=\"0\" width=\"1\" height=\"11\"><p>fehler in der email-adresse.</p><p>bitte versuchen sie es nochmal.</p>
<p><br>
</p><a href=\"javascript:history.back();\"><img src=\"http://www.vivaxmedia.de/upload/pics/back.gif\" border=\"0\" width=\"46\" height=\"14\" /></a>
<td valign=\"top\" width=\"84\" > </td>
<td valign=\"top\" width=\"214\"><a href=\"http://www.vivaxmedia.de/front_content.php?idart=40\" target=\"_self\">impressum</a><br />
<a href=\"http://www.vivaxmedia.de/front_content.php?idart=46\" target=\"_self\">datenschutz</a><br />
<a href=\"http://www.vivaxmedia.de/front_content.php?idart=45\" target=\"_self\">agb</a></td>
<td valign=\"top\" width=\"54\" > </td>
</tr>
</table>
</div>";
} else {
#No errors, create and send mail
$mail = new phpmailer;
$mail_body = '<html><head></head><body bgcolor="#ffffff"><table cellspacing="0" cellpadding="2" border="0">';
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if ($key != 'send') {
$mail_body .= "<tr><td>$key</td><td>$value</td></tr>";
}
}
}
$mail_body .= '</table></bo'.'dy></html>';
$mail->Host = "localhost";
$mail->IsHTML(true);
#Get mailer from settings
switch (strtolower("CMS_VALUE[4]")) {
case "smtp" :
$mail->IsSMTP();
$host = "CMS_VALUE[5]";
$user = "CMS_VALUE[6]";
$password = "CMS_VALUE[7]";
if (($host != '') && ($user != '') && ($password != '')) {
$mail-> $SMTPAuth = true;
$mail->Host = $host;
$mail->Username = $user;
$mail->Password = $password;
}
break;
case "mail" :
$mail->IsMail();
break;
case "sendmail" :
$mail->IsSendmail();
break;
case "qmail" :
$mail->IsQmail();
break;
default :
}
$mail->From = "CMS_VALUE[0]";
$mail->Sender = "CMS_VALUE[0]";
$mail->FromName = "CMS_VALUE[2]";
$mail->AddAddress("CMS_VALUE[1]", "");
$mail->Subject = "CMS_VALUE[3]";
$mail->Body = $mail_body;
$mail->WordWrap = 50;
$mail->Send();
#Display message after mail is sent
echo '<div id="contactForm"><table width="906" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td align="left" valign="top" width="36" > </td>
<td align="left" valign="top" width="273"><p>+49 (0) 6221 35 44 873</p><img src="http://www.vivaxmedia.de/upload/pics/space.gif" border="0" width="1" height="11" />
<p>info@vivaxmedia.de</p><img src="http://www.vivaxmedia.de/upload/pics/space.gif" border="0" width="1" height="11" />
<p>hauptstraße 63<br />
69221 dossenheim</p></td>
<td valign="top" style=" background-image:url(http://www.vivaxmedia.de/upload/pics/cont.gif); color:#2dbee7; width:245px; height:130px;"><p>ihre nachricht wurde gesendet.</p><br>
<p>ich werde mich so bald wie möglich mit ihnen in verbindung setzen.</p>
<p></td>
<td valign="top" width="84" > </td>
<td valign="top" width="214"><a href="http://www.vivaxmedia.de/front_content.php?idart=40" target="_self">impressum</a><br />
<a href="http://www.vivaxmedia.de/front_content.php?idart=46" target="_self">datenschutz</a><br />
<a href="http://www.vivaxmedia.de/front_content.php?idart=45" target="_self">agb</a></td>
<td valign="top" width="54" > </td>
</tr>
</table>
</div>';
}
}
?>
Und hier der Validierungscode von rethus:
Code: Alles auswählen
<?php
@session_start();
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : Contact form
* Author(s) : Andreas Lindner
* Copyright : Contenido - four for business
* Created : 12.08.2005
************************************************/
#Includes
cInclude("classes", "class.phpmailer.php");
$reload ="CMS_VALUE[8]";
if (!isset ($_POST['send'])) {
#Form has not been sent yet
cInclude('classes', 'class.article.php');
cInclude('classes', 'class.template.php');
#Create contact form
echo '<form name="kontaktform" id="kontaktform" method="post" action="'.$sess->url("front_content.php?idcat=$idcat&idart=$idart&parentid=$parentid").'">';
echo '<input type="hidden" name="send" value="1">';
if (!is_object($tpl)) {
$tpl = new Template;
}
$tpl->set("s", "ANREDE", mi18n("Anrede"));
$tpl->set("s", "ANREDE_OPTION1", mi18n("Herr"));
$tpl->set("s", "ANREDE_OPTION2", mi18n("Frau"));
$tpl->set("s", "NACHNAME", mi18n("Name"));
$tpl->set("s", "VORNAME", mi18n("Vorname"));
$tpl->set("s", "FIRMA", mi18n("Firma"));
$tpl->set("s", "STRASSE", mi18n("Straße/Nr."));
$tpl->set("s", "PLZORT", mi18n("PLZ/Ort"));
$tpl->set("s", "TELEFON", mi18n("Telefon"));
$tpl->set("s", "EMAIL", mi18n("eMail"));
$tpl->set("s", "ANLIEGEN", mi18n("Nachricht"));
$tpl->set("s", "PFLICHTFELDER", mi18n("Pflichtfelder"));
$tpl->set("s", "ABSCHICKEN", mi18n("Abschicken"));
$tpl->set("s", "LOESCHEN", mi18n("Löschen"));
$tpl->generate($cfgClient[$client]["path"]["frontend"]."templates/kontaktformular.html");
echo '</form>';
} elseif ($_POST['send'] == 1) {
#Form has been sent
#Check user input
$noerrors = true;
$msg = '';
if ($_POST['Vorname'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihren Vornamen ein!")."<br/>";
}
if ($_POST['Nachname'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihren Namen ein!")."'<br/>";
}
if ($_POST['Strasse'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihre Straße ein!")."<br/>";
}
if(empty($_POST['Telefon']) || !preg_match("/^(\+?[0-9 ]{3,}[-\/]?[0-9 ]{3,}]*)$/", $_POST['Telefon']))
{
$noerrors = false;
$msg .= mi18n("Telefonnummer fehlt oder falsch! Format: (02273) 123456")."<br/>";
}
// Wert in Integer umwandeln
$_POST['PLZ'] = (int) $_POST['PLZ'];
if (empty($_POST['PLZ']) || strlen($_POST['PLZ']) < 5 ) {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihre PLZ richtig ein!")."<br/>";
} if ($_POST['EMail'] == '') {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihre EMail-Adresse ein!")."<br/>";
}
if (!empty($_POST['EMail']))
{
$mail_expr = "/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/";
if( !preg_match($mail_expr, $_POST['EMail']) )
{
$noerrors = false;
$msg .= mi18n("Die eingegebene EMail-Adresse ist nicht korrekt!")."<br/>";
}
}
if (empty($_POST['Anliegen']) || strlen($_POST['Anliegen'])< 50) {
$noerrors = false;
$msg .= mi18n("Bitte geben Sie Ihre Anliegen ein!")."<br/>";
}
if ($noerrors == false) {
#Errors have been found
echo "<p style='margin-top:20px; color:#8b0000'><b>".mi18n("Beim Versenden sind folgende Fehler aufgetreten:")."</b></p><br/>";
echo $msg.'<br/>';
echo '<a href="javascript:history.back();">'.mi18n("Zurück").'</a>';
} else {
if(isset($_SESSION['time']) && time()<($_SESSION['time']+ $reload))
{
$nextMail = (double) ceil($reload / 60);
echo "<p><div style='width:100%; text-align:center; color:#b80000; font-weight:bold'>Sie haben diese Email bereits versendet.
Für die nächsten $nextMail Minuten ist dieses Kontaktformular als Spamschutz-Maßnahme gesperrt!</div></p>";
}
else
{
/*Benutzung des Back-Buttons verhindern, damit keine massen-Mails gesendet werden*/
$_SESSION['time'] = time();
#No errors, create and send mail
$mail = new phpmailer;
$mail_body = '<html><head></head><body bgcolor="#ffffff"><table cellspacing="0" cellpadding="2" border="0">';
if (is_array($_POST)) {
foreach ($_POST as $key => $value) {
if ($key != 'send') {
$mail_body .= "<tr><td>$key</td><td>$value</td></tr>";
}
}
}
$mail_body .= '</table></bo'.'dy></html>';
$mail->Host = "localhost";
$mail->IsHTML(true);
#Get mailer from settings
switch (strtolower("CMS_VALUE[4]")) {
case "smtp" :
$mail->IsSMTP();
$host = "CMS_VALUE[5]";
$user = "CMS_VALUE[6]";
$password = "CMS_VALUE[7]";
if (($host != '') && ($user != '') && ($password != '')) {
$mail-> $SMTPAuth = true;
$mail->Host = $host;
$mail->Username = $user;
$mail->Password = $password;
}
break;
case "mail" :
$mail->IsMail();
break;
case "sendmail" :
$mail->IsSendmail();
break;
case "qmail" :
$mail->IsQmail();
break;
default :
}
$mail->From = "CMS_VALUE[0]";
$mail->FromName = "CMS_VALUE[2]";
$mail->AddAddress("CMS_VALUE[1]", "");
$mail->Subject = "CMS_VALUE[3]";
$mail->Body = $mail_body;
$mail->WordWrap = 50;
$mail->Send();
#Display message after mail is sent
echo "<center>".mi18n("Ihr Anliegen wurde uns übermittelt. Vielen Dank!")."</center><br/>";
}
}
}
?>
Vielleicht kann mir ja jemand mit Erfahrung nen Tipp gebenwie das Ganze umzusetzen ist.
Gruß, Moe