Version 2
This commit is contained in:
105
pagecontent/action-register.php
Normal file
105
pagecontent/action-register.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
$email = iconv('UTF-8','ASCII//TRANSLIT',addslashes(htmlentities(substr($_POST["email"], 0, 256), ENT_QUOTES, 'UTF-8')));
|
||||
$username = iconv('UTF-8','ASCII//TRANSLIT',addslashes(htmlentities(substr($_POST["username"], 0, 64), ENT_QUOTES, 'UTF-8')));
|
||||
$password = htmlentities(substr($_POST["password"], 0, 256));
|
||||
$password_repeat = htmlentities(substr($_POST["password_repeat"], 0, 256));
|
||||
|
||||
|
||||
if(empty($email) || empty($username) || empty($password) || empty($password_repeat) || !filter_var($email, FILTER_VALIDATE_EMAIL) ) {
|
||||
print("incompleteUserdata");
|
||||
die();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `VokabelBox2Users` WHERE `username` = '$username'";
|
||||
$result_articles = $conn->query($sql);
|
||||
|
||||
if(mysqli_num_rows($result_articles))
|
||||
{
|
||||
print("usernameRegistered");
|
||||
die();
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `VokabelBox2Users` WHERE `email` = '$email'";
|
||||
$result_articles = $conn->query($sql);
|
||||
|
||||
if(mysqli_num_rows($result_articles))
|
||||
{
|
||||
print("emailRegistered");
|
||||
die();
|
||||
}
|
||||
|
||||
if($password != $password_repeat) {
|
||||
print("noAgreement");
|
||||
die();
|
||||
}
|
||||
|
||||
$captcha = $_POST["captcha"];
|
||||
$secret = "6LdfJZkaAAAAABL6KR5GQll8xxkPRJZGYknBYKeQ";
|
||||
$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secret."&response=".$captcha."&remoteip=".$_SERVER["REMOTE_ADDR"]), true);
|
||||
|
||||
if ($response["success"] != false) {
|
||||
|
||||
}
|
||||
else {
|
||||
print("noCaptcha");
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$password = hash('sha512',$password);
|
||||
|
||||
|
||||
$_SESSION["Benutzername"] = $username;
|
||||
$_SESSION["Passwort"] = $password;
|
||||
$_SESSION["Email"] = $email;
|
||||
|
||||
$code = '';
|
||||
$string = "0123456789";
|
||||
for ($i = 1; $i <= 4; $i++)
|
||||
{
|
||||
$zufallszahl = rand(0, 9);
|
||||
$zufallszahl = substr($string, $zufallszahl, 1);
|
||||
$code = $code . $zufallszahl;
|
||||
}
|
||||
|
||||
$_SESSION["code"] = $code;
|
||||
$_SESSION["codeFails"] = 0;
|
||||
|
||||
$betreff = "Willkommen bei VokSpace!";
|
||||
$from = "VokSpace";
|
||||
$text = '
|
||||
<html">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Bitte bestätigen Sie Ihr Konto</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>
|
||||
<h5 style="font-family: Arial;color:#fff;margin: 5px 0;font-size:15px">Ihr Benutzerkonto wird erst bei der erfolgreichen Eingabe dieses Code aktiviert. Momentan besteht noch kein Anspruch auf Email-Adresse und Benutzername.<br>Wenn Sie das Fenster versehentlich geschlossen haben, können Sie einfach ein neues Konto erstellen.</h5>
|
||||
</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");
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user