75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
// Neue E-Mail wird geholts
|
|
$email = substr($_POST["email"], 0, 256);
|
|
|
|
// Testen, ob ausgefüllt
|
|
if(empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL) ) {
|
|
print("incompleteUserdata");
|
|
die();
|
|
}
|
|
|
|
// Schauen, ob E-Mail registriert ist
|
|
$sql = "SELECT * FROM `VokabelBox2Users` WHERE `email` = '$email'";
|
|
$result_articles = $conn->query($sql);
|
|
|
|
if(!mysqli_num_rows($result_articles))
|
|
{
|
|
print("emailUnknown");
|
|
die();
|
|
}
|
|
|
|
// Eingegebene E-Mail als Session hinterlegen
|
|
$_SESSION["forgot-password-email"] = $email;
|
|
|
|
// Neuen Code generieren
|
|
$code = '';
|
|
$string = "0123456789";
|
|
for ($i = 1; $i <= 4; $i++)
|
|
{
|
|
$zufallszahl = rand(0, 9);
|
|
$zufallszahl = substr($string, $zufallszahl, 1);
|
|
$code = $code . $zufallszahl;
|
|
}
|
|
|
|
// Neuer Code wird als Session gesetzt
|
|
$_SESSION["forgot-password-code"] = $code;
|
|
// Anzahl d. Fehlversuche wird zurückgesetzt
|
|
$_SESSION["forgot-password-codeFails"] = 0;
|
|
|
|
$betreff = "Passwort zurücksetzen";
|
|
$from = "VokSpace";
|
|
$text = '
|
|
<html">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
<title>Bitte bestätige deine neue E-Mail-Adresse</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
</head>
|
|
<body style="background-color: #3d434b;padding: 20px;">
|
|
<div style="margin-top: 50px;position:relative;overflow:hidden;background-color: #212529;border-radius: 30px;">
|
|
<div style="width: 50px;float:right;display:block;background-color: rgba(249,130,72,1);height:200px">
|
|
</div>
|
|
<div style="width: auto;float:left;display:block;padding:20px">
|
|
<h2 style="font-family: Arial;color:#fff;margin: 5px 0;font-size:40px">Ihr Code: ' . $code . '</h2>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>';
|
|
|
|
$header = "MIME-Version: 1.0\r\n";
|
|
$header .= "Content-type: text/html; charset=utf-8\r\n";
|
|
|
|
$header .= "From: VokSpace\r\n";
|
|
$header .= "Reply-To: tim@timvandenboom.de\r\n";
|
|
// $header .= "Cc: $cc\r\n"; // falls an CC gesendet werden soll
|
|
$header .= "X-Mailer: PHP ". phpversion();
|
|
|
|
mail($email, $betreff, $text, $header);
|
|
|
|
|
|
print("true");
|
|
|
|
|
|
?>
|