function signUp($mysqli) { if (isset($_POST['submit'])) { if (!empty($_POST['vorname'])) { $vorname = trim(htmlentities($_POST['vorname'], ENT_QUOTES, "UTF-8")); $vorname = $mysqli->real_escape_string($vorname); if (!empty($_POST['nachname'])) { $nachname = trim(htmlentities($_POST['nachname'], ENT_QUOTES, "UTF-8")); $nachname = $mysqli->real_escape_string($nachname); if (!empty($_POST['email'])) { $email = trim(htmlentities($_POST['email'], ENT_QUOTES, "UTF-8")); $email = $mysqli->real_escape_string($email); /* Emailformat */ $beginning = "[a-zA-Z\\d][\\w\\.-]*[a-zA-Z\\d]"; $end = "[a-zA-Z\\d][\\w\\.-]*\\.[a-zA-Z]{2,4}"; $regExp = "/^" . $beginning . "@" . $end . "\$/"; if (preg_match($regExp, $email)) { /* Email bereits eingetragen */ $emailExist = $mysqli->query("SELECT id FROM users WHERE email = '{$email}'"); if ($emailExist->num_rows == 0) { if (!empty($_POST['password'])) { if (strlen($_POST['password']) > 7) { if ($_POST['password'] === $_POST['password2']) { $password = md5(trim(htmlentities($_POST['password'], ENT_QUOTES, "UTF-8"))); $activationCode = createVerToken($mysqli); $date = date('Y-m-d H:i:s'); $write = $mysqli->query("INSERT INTO users VALUES \r\n \t\t\t\t\t\t\t\t \t ('', '{$vorname}', '{$nachname}', '{$email}', '{$password}', \r\n \t\t\t\t\t\t\t\t \t '{$date}', '{$date}', '{$date}', 'customer', '{$activationCode}', '1') "); /* Addresse auf leer setzen */ $writeAdress = $mysqli->query("INSERT INTO adresses VALUES ('', '', '', '', '', '{$date}') "); /* Info an mich das sich jemand neues registriert hat */ /* Email an mich zur Info */ $header = "From: <***>\n"; $header .= "Reply-To: ***\n"; $header .= "Content-Type: text/html; charset=utf-8 \n"; $inhalt = $vorname . " " . $nachname . " hat sich am " . $date . " registriert. <br> Die Emailadresse lautet: " . $email; $mailToMe = mail("***", "es hat sich ein neuer User registriert!!!", $inhalt, $header); if (sendMail($activationCode, $email) === true) { return 1; } else { return 2; } } else { return "Die Passwortwiederholung war nicht identisch."; } } else { return "Das Password muss wenig 8 Zeichen lang sein."; } } else { return "Sie haben kein Password eingegeben."; } } else { return "Diese Emailadresse existiert bereits."; } } else { return "Sie haben keine gültige Emailadresse angegeben."; } } else { return "Sie haben keine Emailadresse angegeben."; } } else { return "Sie haben keinen Nachnamen angegeben."; } } else { return "Sie haben keinen Vornamen angegeben."; } } }
function signUp($mysqli) { if (isset($_POST['submit'])) { if (!empty($_POST['userName'])) { $userName = trim(htmlentities($_POST['userName'], ENT_QUOTES, "UTF-8")); $userName = $mysqli->real_escape_string($userName); if (!empty($_POST['email'])) { $email = trim(htmlentities($_POST['email'], ENT_QUOTES, "UTF-8")); $email = $mysqli->real_escape_string($email); // Emailformat $beginning = "[a-zA-Z\\d][\\w\\.-]*[a-zA-Z\\d]"; $end = "[a-zA-Z\\d][\\w\\.-]*\\.[a-zA-Z]{2,4}"; $regExp = "/^" . $beginning . "@" . $end . "\$/"; if (preg_match($regExp, $email)) { // Email bereits eingetragen und signupmethod site, da auch als FBLogin sein kann $emailExist = $mysqli->query("SELECT id FROM users WHERE email = '{$email}' AND signUpMethod = 'site' "); if ($emailExist->num_rows == 0) { if (!empty($_POST['password'])) { if (strlen($_POST['password']) > 3) { $password = md5(trim(htmlentities($_POST['password'], ENT_QUOTES, "UTF-8"))); $activationCode = createVerToken($mysqli); $date = date('Y-m-d H:i:s'); $time = time(); // indexTest $indexPage = trim(htmlentities($_POST['indexPage'], ENT_QUOTES, "UTF-8")); $indexPage = $mysqli->real_escape_string($indexPage); $write = $mysqli->query("INSERT INTO users VALUES \r\n \t\t\t\t\t\t\t\t \t ('', 'site', '{$userName}', '{$email}', '{$password}', '', '', '', '', '', '0',\r\n \t\t\t\t\t\t\t\t \t'{$date}', '{$date}', '{$date}', '0', 'user', '{$indexPage}', '{$activationCode}', '0') "); // Hole userId $getId = $mysqli->query("SELECT id FROM users WHERE email = '{$email}' "); $userArray = $getId->fetch_array(); $userId = $userArray['id']; // Neue Session erstellen session_regenerate_id(); $sessionId = session_id(); $_SESSION['userId'] = $userId; $_SESSION['sessionId'] = $sessionId; $write = $mysqli->query("INSERT INTO sessions VALUES ('{$userId}', '{$sessionId}', '{$time}')"); // Info an mich das sich jemand neues registriert hat zur Info $header = "From: <***>\n"; $header .= "Reply-To: ***\n"; $header .= "Content-Type: text/html; charset=utf-8 \n"; $inhalt = $userName . " hat sich am " . $date . " registriert. <br> Die Emailadresse lautet: " . $email; $mailToMe = mail("***", "es hat sich ein neuer User registriert!!!", $inhalt, $header); // hier Email an user mit dem Activation Code if (sendMail($activationCode, $email) === true) { return 1; } else { return 2; } } else { return "Das Password muss wenigstens 4 Zeichen lang sein."; } } else { return "Du hast kein Password eingegeben."; } } else { return "Diese Emailadresse existiert bereits."; } } else { return "Du hast keine gültige Emailadresse angegeben."; } } else { return "Du hast keine Emailadresse angegeben."; } } else { return "Du hast keinen Namen angegeben."; } } }