Mein Mailing-Script versendet erfolgreich Mails und diese kommen auch im Postfach an,
jedoch wird das Formular nicht resettet.
Auch eine Bestätigung darüber dass der Versand erfolgte/nicht erfolgte bleibt aus.
Meldungen wie fehlende Eingaben werden angezeigt, verschwinden nach dem versenden allerdings auch nicht.
Hier ausprobieren: http://blechlavine.bplaced.net
Hier nochmal contact.php:
[COLOR=#000000][FONT=Consolas][COLOR=#800000]<?php[/COLOR]
session_start();
header([COLOR=#a31515]'Cache-Control: no-cache, must-revalidate'[/COLOR]);
header([COLOR=#a31515]'Expires: Mon, 26 Jul 1997 05:00:00 GMT'[/COLOR]);
header([COLOR=#a31515]'Content-type: application/json'[/COLOR]);
[COLOR=#0000ff]require_once[/COLOR] ([COLOR=#a31515]'db_connect.php'[/COLOR]);
[COLOR=#008000]//Language-Session[/COLOR]
[COLOR=#0000ff]if[/COLOR](!isset($_GET[[COLOR=#a31515]"language"[/COLOR]]))
{
[COLOR=#0000ff]if[/COLOR](!isset($_SESSION[[COLOR=#a31515]"language"[/COLOR]]))
{
include([COLOR=#a31515]'../lang/de.php'[/COLOR]);
$_SESSION[[COLOR=#a31515]"language"[/COLOR]] = [COLOR=#a31515]'de'[/COLOR];
}
[COLOR=#0000ff]else[/COLOR]
{
include([COLOR=#a31515]'../lang/'[/COLOR] . $_SESSION[[COLOR=#a31515]"language"[/COLOR]] . [COLOR=#a31515]'.php'[/COLOR]);
}
}
[COLOR=#0000ff]else[/COLOR]
{
$_SESSION[[COLOR=#a31515]"language"[/COLOR]] = $_GET[[COLOR=#a31515]"language"[/COLOR]];
include([COLOR=#a31515]'../lang/'[/COLOR] . $_SESSION[[COLOR=#a31515]"language"[/COLOR]] . [COLOR=#a31515]'.php'[/COLOR]);
}
[COLOR=#008000]//End of Language-Session[/COLOR]
$contact_errorname = $lang[[COLOR=#a31515]'contact_errorname'[/COLOR]];
$contact_erroremail = $lang[[COLOR=#a31515]'contact_erroremail'[/COLOR]];
$contact_erroremail2 = $lang[[COLOR=#a31515]'contact_erroremail2'[/COLOR]];
$contact_errormessage = $lang[[COLOR=#a31515]'contact_errormessage'[/COLOR]];
$contact_fail = $lang[[COLOR=#a31515]'contact_fail'[/COLOR]];
$contact_success = $lang[[COLOR=#a31515]'contact_success'[/COLOR]];
$statement = $db->query([COLOR=#a31515]'[/COLOR][COLOR=#0000ff]SELECT[/COLOR][COLOR=#a31515] mail_contact [/COLOR][COLOR=#0000ff]FROM[/COLOR][COLOR=#a31515] settings[/COLOR][COLOR=#a31515]'[/COLOR]);
$admin_email = $statement->fetch()[[COLOR=#a31515]'mail_contact'[/COLOR]];
$message_min_length = [COLOR=#09885a]5[/COLOR];
[COLOR=#008000]//PHPmailer v6 Setup[/COLOR]
[COLOR=#0000ff]use[/COLOR] PHPMailer\PHPMailer\PHPMailer;
[COLOR=#0000ff]use[/COLOR] PHPMailer\PHPMailer\Exception;
[COLOR=#0000ff]require[/COLOR] [COLOR=#a31515]'Exception.php'[/COLOR];
[COLOR=#0000ff]require[/COLOR] [COLOR=#a31515]'PHPMailer.php'[/COLOR];
[COLOR=#0000ff]require[/COLOR] [COLOR=#a31515]'SMTP.php'[/COLOR];
[COLOR=#0000ff]class[/COLOR] Contact_Form
{
[COLOR=#0000ff]function[/COLOR] __construct($details, $admin_email, $message_min_length, $contact_errorname, $contact_erroremail, $contact_erroremail2, $contact_errormessage, $contact_fail, $contact_success)
{
[COLOR=#0000ff]$this[/COLOR]->name = stripslashes($details[[COLOR=#a31515]'name'[/COLOR]]);
[COLOR=#0000ff]$this[/COLOR]->email = trim($details[[COLOR=#a31515]'email'[/COLOR]]);
[COLOR=#0000ff]$this[/COLOR]->subject = [COLOR=#a31515]'Blechlavine.com - Kontaktnachricht eingegangen'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->message = stripslashes($details[[COLOR=#a31515]'message'[/COLOR]]);
[COLOR=#0000ff]$this[/COLOR]->admin_email = $admin_email;
[COLOR=#0000ff]$this[/COLOR]->message_min_length = $message_min_length;
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]1[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_html = [COLOR=#a31515]''[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->contact_errorname = $contact_errorname;
[COLOR=#0000ff]$this[/COLOR]->contact_erroremail = $contact_erroremail;
[COLOR=#0000ff]$this[/COLOR]->contact_erroremail2 = $contact_erroremail2;
[COLOR=#0000ff]$this[/COLOR]->contact_errormessage = $contact_errormessage;
[COLOR=#0000ff]$this[/COLOR]->contact_fail = $contact_fail;
[COLOR=#0000ff]$this[/COLOR]->contact_success = $contact_success;
}
[COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]function[/COLOR] validateEmail()
{
$regex =[COLOR=#811f3f]'/[/COLOR]^[COLOR=#811f3f]([\w-][/COLOR]+[COLOR=#811f3f](?:\.[\w-][/COLOR]+[COLOR=#811f3f])[/COLOR]*[COLOR=#811f3f])@((?:[\w-][/COLOR]+[COLOR=#811f3f]\.)[/COLOR]*[COLOR=#811f3f]\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)[/COLOR]$[COLOR=#811f3f]/i'[/COLOR];
[COLOR=#0000ff]if[/COLOR] ([COLOR=#0000ff]$this[/COLOR]->email == [COLOR=#a31515]''[/COLOR])
[COLOR=#0000ff]return[/COLOR] [COLOR=#0000ff]false[/COLOR];
$string = preg_replace($regex, [COLOR=#a31515]''[/COLOR], [COLOR=#0000ff]$this[/COLOR]->email);
[COLOR=#0000ff]return[/COLOR] empty($string);
}
[COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]function[/COLOR] validateFields()
{
[COLOR=#008000]// Check name[/COLOR]
[COLOR=#0000ff]if[/COLOR](![COLOR=#0000ff]$this[/COLOR]->name)
{
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_errorname . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]0[/COLOR];
}
[COLOR=#008000]// Check email[/COLOR]
[COLOR=#0000ff]if[/COLOR](![COLOR=#0000ff]$this[/COLOR]->email)
{
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_erroremail . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]0[/COLOR];
}
[COLOR=#008000]// Check valid email[/COLOR]
[COLOR=#0000ff]if[/COLOR]( [COLOR=#0000ff]$this[/COLOR]->email &&![COLOR=#0000ff]$this[/COLOR]->validateEmail() )
{
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_erroremail2 . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]0[/COLOR];
}
[COLOR=#008000]// Check message length[/COLOR]
[COLOR=#0000ff]if[/COLOR](![COLOR=#0000ff]$this[/COLOR]->message || strlen([COLOR=#0000ff]$this[/COLOR]->message) < [COLOR=#0000ff]$this[/COLOR]->message_min_length)
{
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_errormessage . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]0[/COLOR];
}
}
[COLOR=#0000ff]private[/COLOR] [COLOR=#0000ff]function[/COLOR] sendEmail()
{
[COLOR=#008000]//PHPmailer v6 Instanz[/COLOR]
$oMailer = [COLOR=#0000ff]new[/COLOR] PHPMailer;
$oMailer->CharSet = [COLOR=#a31515]'UTF-8'[/COLOR];
[COLOR=#008000]// SMTP aktivieren[/COLOR]
$oMailer->isSMTP();
[COLOR=#008000]// SMTP-Server[/COLOR]
$oMailer->Host =[COLOR=#a31515]'smtp.strato.de'[/COLOR];
[COLOR=#008000]// SMTP Authentifizierung aktivieren[/COLOR]
$oMailer->SMTPAuth = [COLOR=#0000ff]true[/COLOR];
[COLOR=#008000]// SMTP Benutzer[/COLOR]
$oMailer->Username = [COLOR=#0000ff]$this[/COLOR]->admin_email;
[COLOR=#008000]// SMTP Benutzer Passwort[/COLOR]
$oMailer->Password = [COLOR=#a31515]'xxxxx'[/COLOR];
[COLOR=#008000]// Verbindungssicherheit setzen ( SSL und TLS möglich )[/COLOR]
$oMailer->SMTPSecure = [COLOR=#a31515]'ssl'[/COLOR];
[COLOR=#008000]// Verbindungsport festlegen[/COLOR]
$oMailer->Port = [COLOR=#09885a]465[/COLOR];
[COLOR=#008000]// Absender Adresse setzen[/COLOR]
$oMailer->From = [COLOR=#0000ff]$this[/COLOR]->email;
[COLOR=#008000]// Absender Alias setzen[/COLOR]
$oMailer->FromName = [COLOR=#0000ff]$this[/COLOR]->name;
[COLOR=#008000]// Empfänger Adresse und Alias hinzufügen[/COLOR]
$oMailer->addAddress([COLOR=#0000ff]$this[/COLOR]->admin_email, [COLOR=#a31515]'Webmaster Blechlavine'[/COLOR]);
[COLOR=#008000]// HTML aktivieren[/COLOR]
$oMailer->isHTML([COLOR=#0000ff]true[/COLOR]);
[COLOR=#008000]// Betreff[/COLOR]
$oMailer->Subject = [COLOR=#a31515]'Blechlavine.com - Nachricht eingegangen'[/COLOR];
[COLOR=#008000]// Der Nachrichteninhalt als HTML[/COLOR]
$oMailer->Body = [COLOR=#0000ff]$this[/COLOR]->message;
[COLOR=#008000]// Alternativer Nachrichteninhalt für Clients, die kein HTML darstellen[/COLOR]
$oMailer->AltBody = strip_tags($oMailer->Body);
[COLOR=#008000]//PHPmailer v6 Versand prüfen[/COLOR]
[COLOR=#0000ff]if[/COLOR](!$oMailer->send())
{
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_fail . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]0[/COLOR];
}
[COLOR=#0000ff]else[/COLOR]
{
[COLOR=#0000ff]$this[/COLOR]->response_status = [COLOR=#09885a]1[/COLOR];
[COLOR=#0000ff]$this[/COLOR]->response_html .= [COLOR=#a31515]'<p>'[/COLOR] . [COLOR=#0000ff]$this[/COLOR]->contact_success . [COLOR=#a31515]'</p>'[/COLOR];
[COLOR=#0000ff]exit[/COLOR];
}
}
[COLOR=#0000ff]public[/COLOR] [COLOR=#0000ff]function[/COLOR] sendRequest()
{
[COLOR=#0000ff]$this[/COLOR]->validateFields();
[COLOR=#0000ff]if[/COLOR]([COLOR=#0000ff]$this[/COLOR]->response_status)
[COLOR=#0000ff]$this[/COLOR]->sendEmail();
$response = array();
$response[[COLOR=#a31515]'status'[/COLOR]] = [COLOR=#0000ff]$this[/COLOR]->response_status;
$response[[COLOR=#a31515]'html'[/COLOR]] = [COLOR=#0000ff]$this[/COLOR]->response_html;
echo json_encode($response);
}
}
$contact_form = [COLOR=#0000ff]new[/COLOR] Contact_Form($_POST, $admin_email, $message_min_length, $contact_errorname, $contact_erroremail, $contact_erroremail2, $contact_errormessage, $contact_fail, $contact_success);
$contact_form->sendRequest();
[/FONT][/COLOR]
[COLOR=#800000][FONT=Consolas]?[/FONT][/COLOR][COLOR=#800000][FONT=Consolas]>
[/FONT][/COLOR]
Alles anzeigen
der JS-Teil:
[COLOR=#000000][FONT=Consolas][COLOR=#008000]/* ==================================================[/COLOR]
[COLOR=#008000] Contact Form[/COLOR]
[COLOR=#008000]================================================== */[/COLOR]
BRUSHED.contactForm = [COLOR=#0000ff]function[/COLOR](){
$([COLOR=#a31515]"#contact-submit"[/COLOR]).on([COLOR=#a31515]'click'[/COLOR],[COLOR=#0000ff]function[/COLOR]() {
$contact_form = $([COLOR=#a31515]'#contact-form'[/COLOR]);
[COLOR=#0000ff]var[/COLOR] fields = $contact_form.serialize();
$.ajax({
type: [COLOR=#a31515]"POST"[/COLOR],
url: [COLOR=#a31515]"_include/php/contact.php"[/COLOR],
data: fields,
dataType: [COLOR=#a31515]'json'[/COLOR],
success: [COLOR=#0000ff]function[/COLOR](response) {
[COLOR=#0000ff]if[/COLOR](response.status){
$([COLOR=#a31515]'#contact-form input'[/COLOR]).val([COLOR=#a31515]''[/COLOR]);
$([COLOR=#a31515]'#contact-form textarea'[/COLOR]).val([COLOR=#a31515]''[/COLOR]);
}
$([COLOR=#a31515]'#response'[/COLOR]).empty().html(response.html);
}
});
[COLOR=#0000ff]return[/COLOR] [COLOR=#0000ff]false[/COLOR];
});
[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]}
[/FONT][/COLOR]
Alles anzeigen
und das Formular selbst, falls das hilft:
[COLOR=#000000][FONT=Consolas][COLOR=#800000]<form[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"contact-form"[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"contact-form"[/COLOR] [COLOR=#ff0000]action[/COLOR]=[COLOR=#0000ff]"#"[/COLOR][COLOR=#800000]>[/COLOR]
[COLOR=#800000]<p[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"contact-name"[/COLOR][COLOR=#800000]>[/COLOR]
[COLOR=#800000]<input[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"contact_name"[/COLOR] [COLOR=#ff0000]type[/COLOR]=[COLOR=#0000ff]"text"[/COLOR] [COLOR=#ff0000]placeholder[/COLOR]=[COLOR=#0000ff]"[/COLOR][COLOR=#800000]<?php[/COLOR] print $lang[[COLOR=#a31515]'contact_yourname'[/COLOR]]; [COLOR=#800000]?[/COLOR][COLOR=#800000]>[/COLOR][COLOR=#0000ff]"[/COLOR] [COLOR=#ff0000]value[/COLOR]=[COLOR=#0000ff]""[/COLOR] [COLOR=#ff0000]name[/COLOR]=[COLOR=#0000ff]"name"[/COLOR] [COLOR=#800000]/>[/COLOR]
[COLOR=#800000]</p>[/COLOR]
[COLOR=#800000]<p[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"contact-email"[/COLOR][COLOR=#800000]>[/COLOR]
[COLOR=#800000]<input[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"contact_email"[/COLOR] [COLOR=#ff0000]type[/COLOR]=[COLOR=#0000ff]"text"[/COLOR] [COLOR=#ff0000]placeholder[/COLOR]=[COLOR=#0000ff]"[/COLOR][COLOR=#800000]<?php[/COLOR] print $lang[[COLOR=#a31515]'contact_youremail'[/COLOR]]; [COLOR=#800000]?[/COLOR][COLOR=#800000]>[/COLOR][COLOR=#0000ff]"[/COLOR] [COLOR=#ff0000]value[/COLOR]=[COLOR=#0000ff]""[/COLOR] [COLOR=#ff0000]name[/COLOR]=[COLOR=#0000ff]"email"[/COLOR] [COLOR=#800000]/>[/COLOR]
[COLOR=#800000]</p>[/COLOR]
[COLOR=#800000]<p[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"contact-message"[/COLOR][COLOR=#800000]>[/COLOR]
[COLOR=#800000]<textarea[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"contact_message"[/COLOR] [COLOR=#ff0000]placeholder[/COLOR]=[COLOR=#0000ff]"[/COLOR][COLOR=#800000]<?php[/COLOR] print $lang[[COLOR=#a31515]'contact_yourmessage'[/COLOR]]; [COLOR=#800000]?[/COLOR][COLOR=#800000]>[/COLOR][COLOR=#0000ff]"[/COLOR] [COLOR=#ff0000]name[/COLOR]=[COLOR=#0000ff]"message"[/COLOR] [COLOR=#ff0000]rows[/COLOR]=[COLOR=#0000ff]"15"[/COLOR] [COLOR=#ff0000]cols[/COLOR]=[COLOR=#0000ff]"40"[/COLOR][COLOR=#800000]></textarea>[/COLOR]
[COLOR=#800000]</p>[/COLOR]
[COLOR=#800000]<p[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"contact-submit"[/COLOR][COLOR=#800000]>[/COLOR]
[COLOR=#800000]<a[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"contact-submit"[/COLOR] [COLOR=#ff0000]class[/COLOR]=[COLOR=#0000ff]"submit"[/COLOR] [COLOR=#ff0000]href[/COLOR]=[COLOR=#0000ff]"#"[/COLOR][COLOR=#800000]><?php[/COLOR] print $lang[[COLOR=#a31515]'contact_sendmessage'[/COLOR]]; [COLOR=#800000]?[/COLOR][COLOR=#800000]></a>[/COLOR]
[COLOR=#800000]</p>[/COLOR]
[COLOR=#800000]<div[/COLOR] [COLOR=#ff0000]id[/COLOR]=[COLOR=#0000ff]"response"[/COLOR][COLOR=#800000]></div>[/COLOR]
[/FONT][/COLOR]
[COLOR=#800000][FONT=Consolas]</form>
[/FONT][/COLOR]
Alles anzeigen
Ich weiß leider nicht was dazu noch fehlt.
Bin wie immer sehr dankbar!