Sehr gerne Ich habe sensible Daten entfernt:
PHP
<?php
$error=0;
$send =0;
switch($_POST['auswahl'])
{
case 'eins':
$email = 'eins@xxx.de';
break;
case 'zwei':
$email = 'zwei@xxx.de';
break;
case 'drei':
$email = 'drei@xxx.de';
break;
}
if (strlen($_POST['vorname']) > 0 && strlen($_POST['nachname']) > 0 && strlen($_POST['email']) > 0 && strlen($_POST['nachricht']) > 0 && strlen($_POST['captchaname']) > 0)
{
$empfaenger = $email;
$betreff = 'Nachricht von der Webseite xxx';
$nachricht = 'Vorname: '.$_POST['vorname'].'<br>';
$nachricht .= 'Nachname: '.$_POST['nachname'].'<br>';
$nachricht .= 'E-Mail-Adresse: <a href="mailto:'.$_POST['email'].'">'.$_POST['email'].'</a><br><br>';
$nachricht .= 'Nachricht: <br>';
$nachricht .= nl2br($_POST['nachricht']);
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= "Content-type: text/html; charset=utf-8". "\r\n";
$header .= 'From: xxx' . "\r\n";
mail($empfaenger, $betreff, $nachricht, $header);
$send=1;
}
else
{
//$send=2;
//echo '<p>Bitte füllen Sie alle Felder aus.</p><br><input type="button" value="Zurück" onclick="history.back();" />';
}
?>
<?php if ($send==1){?>
<div class="infoblock">Vielen Dank für Ihre Nachricht. Wir werden uns schnellst möglichst bei Ihnen melden.</div>
<?php }?>
<?php if ($send==2){?>
<div class="infoblock">Bitte füllen Sie alle Felder aus.</div>
<?php }?>
<we:checkForm match="myForm" type="id" mandatory="inputName1,inputNachname1,inputMail1,captchaname" onError="dealFormError">Bitte füllen Sie alle Pflichtfelder aus und überprüfen Sie Ihre E-Mail-Adresse.</we:checkForm>
<script type="text/javascript">
function dealFormError(form,missingFields,wrongEmails,wrongPassword){
var wrongFields = missingFields.concat(wrongEmails);
msg = "Bitte kontrollieren Sie Ihre Eingaben!";
if(missingFields.length>0){
msg += "\nDie Felder mit Stern (*) sind Pflichtfelder.";
}
if(wrongEmails.length>0){
msg += "\nIhre E-Mail-Adresse scheint nicht korrekt zu sein.";
}
// msg += wrongFields;
alert(msg);
}
</script>
<we:form nameid="myForm" method="post" required="inputName1,inputNachname1,inputMail1,captchaname">
<div class="form-group">
<label>Empfänger</label>
<select name="auswahl" size="1" class=" form-control required" type="text" >
<option value="eins">eins</option>
<option value="zwei">zwei</option>
<option value="drei">drei</option>
</select>
</div>
<div class="form-group">
<input id="inputName1" name="vorname" class="form-control required" type="text" placeholder="Vorname*">
</div>
<div class="form-group">
<input id="inputNachname1" name="nachname" class="form-control required" type="text" placeholder="Nachname*">
</div>
<div class="form-group">
<input id="inputMail1" name="email" class="form-control required email" type="email" placeholder="E-Mail*">
</div>
<div class="form-group">
<textarea id="inputAnliegen1" class="form-control" name="nachricht" rows="5" placeholder="Ihr Anliegen"></textarea>
</div>
<div class="form-group captcha-form">
<div class="captcha_container">
<we:captcha height="40" width="200" alt="Zahlencode" bgcolor="#edf6fa" case="mix" fontcolor="#000000" fontsize="20" maxlength="5" skip="i,I,l,L,0,o,O,1,g,9" stylecolor="#cccccc" subset="alphanum" type="png" />
<we:img id="680" onClick="refresh();" class="refresh-button"/>
<input id="captchaname" name="captchaname" class="form-control required" type="text" placeholder="Captcha eingeben*" pass_alt="" />
</div>
<script>
function refresh(){
var xhr=new XMLHttpRequest();
xhr.open('POST',window.location.origin+window.location.pathname);
xhr.addEventListener('loadend',function(){
var parser=new DOMParser();
var doc=parser.parseFromString(xhr.responseText, 'text/html');
document.querySelector('.captcha_container > img').replaceWith(doc.querySelector('.captcha_container > img'));
});
xhr.send();
}
refresh();
</script>
<we:ifCaptcha name="captchaname" formname="myForm">
<we:formmail/>
<we:else />
</we:ifCaptcha>
</div>
<div class="form-group" style=" clear: both; display: flex;">
<button type="submit" class="btn">Absenden</button>
</div>
</we:form>
Display More