Moin moin,
Ich hoffe, ich stelle meine Frage im richtigen Forum...
ich habe ein Formular als Seiten-Template erstellt.
Auf der eigentlichen Seite habe ich nur den Einleitungstext eingetragen und binde dann das Formular ein, indem ich die entsprechende Vorlage auswähle.
Es funktioniert alles, abgesehen vom senden der E-Mail.
Die Felder werden überprüft und ggf. die entsprechenden Fehlermeldungen angezeigt (abgesehen vom select-Feld :().
Wenn aber alles richtig ausgefüllt ist, dann lande ich leider nur auf einer 404-Fehlerseite... :( :confused:
Hier das Formular:
http://www.wsbederkesa.de/anmeldung-segelregatta/
Kann mir jemand sagen, wo mein Fehler / meine Fehler liegt bzw. liegen?
Hier der Code, der das Formular verarbeitet:
<?php
/*
Template Name: SREG
*/
?>
<?php
//If the form is submitted
if(isset($_POST['submitted'])) {
if(isset($_POST['g-recaptcha-response'])){
$captcha=$_POST['g-recaptcha-response'];
}
if(!$captcha){
echo '<h2>Bitte das Anti-Spam-Captcha bestätigen.</h2>';
exit;
}
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=SECRETKEYMe&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
if($response.success==false)
{
echo '<h2>You are spammer! Get the @$%K out</h2>';
}else {
//Check to see if the honeypot captcha field was filled in
if(trim($_POST['checking']) !== '') {
$captchaError = true;
} else {
//Check to make sure that the Regatta field is not empty
if(isset($_POST['regatta'])) {
$regattaError = '<br />Bitte wählen Sie eine Regatta aus.';
$hasError = true;
} else {
$regatta = trim($_POST['regatta']);
}
//Check to make sure that the Name field is not empty
if(trim($_POST['name']) === '') {
$nameError = '<br />Ihr Nachname?';
$hasError = true;
} else {
$name = trim($_POST['name']);
}
//Check to make sure that the Vorname field is not empty
if(trim($_POST['vorname']) === '') {
$vornameError = '<br />Ihr Vorname?';
$hasError = true;
} else {
$vorname = trim($_POST['vorname']);
}
//Check to make sure that the Verein field is not empty
if(trim($_POST['verein']) === '') {
$vereinError = '<br />Ihr Verein?';
$hasError = true;
} else {
$verein = trim($_POST['verein']);
}
//Check to make sure that the Vorname field is not empty
if(trim($_POST['bname']) === '') {
$bnameError = '<br />Wie heißt Ihr Boot?';
$hasError = true;
} else {
$bname = trim($_POST['bname']);
}
//Check to make sure that the Verein field is not empty
if(trim($_POST['bklasse']) === '') {
$bklasseError = '<br />Welche Bootsklasse?';
$hasError = true;
} else {
$bklasse = trim($_POST['bklasse']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) === '') {
$emailError = '<br />Bitte geben Sie eine E-Mail-Adresse ein.';
$hasError = true;
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
$emailError = 'Bitte geben Sie eine gültige E-Mail-Adresse ein.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//Check to make sure comments were entered
if(trim($_POST['comments']) === '') {
$commentError = 'Sie haben vergessen, Ihre Nachricht einzugeben.';
$hasError = true;
} else {
if(function_exists('stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}
$anschrift =trim($_POST['anschrift']);
$plz = trim($_POST['plz']);
$ort = trim($_POST['ort']);
$verein = trim($_POST['verein']);
$vkurz = trim($_POST['vkurz']);
$dsv = trim($_POST['dsv']);
$vsname = trim($_POST['vsname']);
$vsvorname = trim($_POST['vsvorname']);
$segelnr = trim($_POST['segelnr']);
$comments = trim($_POST['comments']);
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'ich@example.com';
$subject = 'Anmeldung zur Segelregatta: '.$regatta;
$sendCopy = trim($_POST['sendCopy']);
//create a boundary for the email. This
$boundary = uniqid('np');
//headers - specify your from email address and name here
//and specify the boundary for the email
$headers = "MIME-Version: 1.0\r\n";
$headers .= "From: WSBederkesa.de <absender@example.com> \r\n";
$headers .= "To: ".$emailTo."\r\n";
$headers .= "Content-Type: multipart/alternative;boundary=" . $boundary . "\r\n";
//here is the content body
$body = "This is a MIME encoded body.";
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-type: text/plain;charset=utf-8\r\n\r\n";
//Plain text body
$body = "Neue Anmeldung zur Segelregatta: " . $regatta . "\n\n";
$body .= "Skipper: ".$vorname;
$body .= "Skipper: " . $vorname;
$body .= " " .$name."\n";
$body .= "Anschrift: ".$anschrift."\n";
$body .= $plz." ".$ort."\n";
$body .= "E-Mail: ".$email."\n\n";
$body .= "Verein: ".$verein."(".$vkurz.")\n";
$body .= "DSV-Reg.: ".$dsv."\n\n";
$body .= "Vorschoter: ".$vsvorname." ".$vsname."\n\n";
$body .= "Boot: ".$Boot."\n";
$body .= "Klasse: ".$bklasse."\n";
$body .= "Segelnummer: ".$segelnr."\n\n";
$body .= "Nachricht:\n".$comments."\n";
$body .= "\r\n\r\n--" . $boundary . "\r\n";
$body .= "Content-type: text/html;charset=utf-8\r\n\r\n";
//Html body
$body .= "
Hier folgt bald die alternative HTML-Version.
Platzhalter.
Platzhalter,
Jens";
$body .= "\r\n\r\n--" . $boundary . "--";
wp_mail($emailTo, $subject, $body, $headers);
if($sendCopy == true) {
$subject = "Ihre Anmeldung zur Segelregatta: ".$regatta;
$headers = 'From: WS Bederkesa <absender@example.com>';
wp_mail($email, $subject, $body, $headers);
}
$emailSent = true;
}
}
}} ?>
<?php get_header(); ?>
Alles anzeigen
und der Beginn des Formulares:
<form action="<?php the_permalink(); ?>" id="Segelregatta" method="post" class="page type-page status-publish has-post-thumbnail hentry">
<table>
<tr>
<td><b><label for="regatta" class="requiredField"><span>Regatta:</span></label></b></td>
<td colspan="2"><select name="regatta" id="regatta" value="<?php if(isset($_POST['regatta'])) echo $_POST['regatta'];?>" >
<option value="" disabled selected>Bitte wählen Sie die Regatta aus.</option>
<option value="Frühjahrsregatta (Ankerball)">Frühjahrsregatta (Ankerball)</option>
<option value="Opti-A-Regatta Beerster Auftakt">Opti-A-Regatta Beerster Auftakt</option>
<option value="Opti-B-Regatta Beerster Auftakt">Opti-B-Regatta Beerster Auftakt</option>
<option value="Best ut Beers">Best ut Beers</option>
<option value="Herbstregatta (Rum-Regatta) ">Herbstregatta (Rum-Regatta) </option></select><i></i></span></div></div>
<?php if($regattaError != '') { ?>
<span class="error"><?=$regattaError;?></span>
<?php } ?>
</tr>
<tr><td colspan="3"><hr></td></tr>
Alles anzeigen