HTML:
<?php include "php/head.php"; ?>
<?php include "php/header.php"; ?>
<div class="aside"></div>
<div class="section">
<h1 class="title">Registration</h1>
<?php
if (!isset($SchachfibelDAO)) {
$SchachfibelDAO = new DBSchachfibelDAOImpl();
} ?>
<div class="registrierung-container">
<script src="script/registration.js"></script>
<div class="register-feld">
<!--Felder für Dateneingabe-->
<form method="post" enctype="multipart/form-data" accept="image/gif,image/jpeg,image/png">
<div class="label">
<label class = "label" for="nutzerName">Nutzername</label>
</div>
<?php $name = (isset($_POST["nutzername"]) && is_string($_POST["nutzername"])) ? htmlspecialchars($_POST["nutzername"]) : "";?>
<input id="nutzerName" class="input" type="text" name="nutzername" onkeyup="showHint(this.value)" placeholder="Nutzername"
value = "<?php echo $name; ?>" required/>
<p id="ajax"></p>
<div class="label">
<label for="email">E-Mail</label>
</div>
<?php $email = (isset($_POST["email"]) && is_string($_POST["email"])) ? htmlspecialchars($_POST["email"]) : "";?>
<input id="email" class="input" type="text" name="email" placeholder="E-Mail" value = "<?php echo $email;?>" required/>
<div class="label"> <label id="passVal" for="nutzerPassword">Password
<!--Rote XXX über dem Passwordfeld-->
<div id="message" class = "mess">
<p id="letter" class="invalid"></p>
<p id="val" class="invalid"></p>
<p id="length" class="invalid"></p>
</div>
</label>
</div>
<?php $password = (isset($_POST["password"]) && is_string($_POST["password"])) ? htmlspecialchars($_POST["password"]) : "";?>
<input id="nutzerPassword" onmousedown="myFunction()" class="input" type="password" name="password" placeholder="Password" value = "<?php echo $password; ?>" required/>
<!--Definitionen von alle X über dem Passwordfeld-->
<div id="textInfo" class="passInfo">
<ul>
<li id="lInf" class="letterInfo"><p >Erstes Zeichen darf nur Buchstaben sein!</p></li>
<li id="mInf" class="valInfo"><p >darf nicht mindestens als 3 Buchstaben und höchstens als 10 Buchstaben sein!</p></li>
<li id="vInf" class="lengthInfo"><p >Weniger als 7 Zeichen ist zwar ok, aber für Passwort ist schwach!</p></li></ul>
</div>
<div class="label">
<label for="confrimePassword">Password wiederholen
<!--Rote X über dem Confrimepasswordfeld-->
<div id="message1" class = "mess1">
<p id="confrime" class="invalid2">
</div>
</label>
</div>
<!--Definition vom roten X-->
<div id="conTextInf" class="conInfo">
<p id="cInf1" class="confrInfo">Passwörter müssen übereinstimmen</p>
</div>
<?php $passwordRepeat = (isset($_POST["passwordRepeat"]) && is_string($_POST["passwordRepeat"])) ? htmlspecialchars($_POST["passwordRepeat"]) : "";?>
<input id="confrimePassword" class="input" onmousedown="myFunction()" type="password" name="passwordRepeat" placeholder="Password wiederholen" value =
"<?php echo $passwordRepeat; ?>" required/>
<!--Bild hochladen-->
<div id="fileHochladen">
<label>Profilbild auswählen
<input type="file" name="files" >
</label>
</div>
<!--AGB checkbox-->
<?php $agb = (isset($_POST["AGB"]) && is_string($_POST["AGB"])) ? htmlspecialchars($_POST["AGB"]) : "";?>
<label class ="labAGB" for="agb">Ich akzeptiere die AGB </label><input type="checkbox" id="agb" class = "agb" name = "AGB" value = "ja"
<?php if ($agb != "") {echo "checked=\"checked\" ";}?> required/>
<!--Button für Registrierung-->
<div class="btn-box">
<input class="buttonReg" type="submit" name="createUser" value="Registrieren">
</div>
</form>
<!--Button für Anmelden-->
<div class="btn-tag">
<a href="./anmelden.php">Bei Schachfibel anmelden</a>
</div><br/>
<?php
/*Abfrage, ob Post existiert*/
if (array_key_exists("createUser", $_POST)) {
$username = htmlspecialchars($_POST["nutzername"]);
$email = htmlspecialchars($_POST["email"]);
$password = htmlspecialchars($_POST["password"]);
$passwordRepeat = htmlspecialchars($_POST["passwordRepeat"]);
$registrationSuccessful = false;
/*Image hochladen*/
$file_name = pathinfo($_FILES["files"]["name"], PATHINFO_FILENAME);
$file_extension = strtolower(pathinfo($_FILES["files"]["name"], PATHINFO_EXTENSION));
$upload_folder = "php/images/";
if(is_dir($upload_folder) == false){ ?>
<div class="fehlerRegistration">
<p>
Folder existiert nicht: Das Bild kann nicht geladen werden!
</p>
</div>
<?php }
$update_path = $upload_folder.$file_name.'.'.$file_extension;
/*Überprüfen, ob ein Bild hochgeladen wurde*/
if($agb == "ja"){
if (isset($_FILES["files"]) && $_FILES["files"]["size"] > Utils::MB * 20) { ?>
<div class="fehlerRegistration">
<p>
Es dürfen nur Dateien kleiner als 20MB hochgeladen werden!;
</p>
</div>
<?php }else if(isset($_FILES["files"]) && $file_name !== ""){
/*Bild wird an den angegebenen Ort verschoben*/
move_uploaded_file($_FILES["files"]["tmp_name"], $update_path);
?>
<div class="fehlerRegistration">
<p>
<?php
/*Erfolgreich registrierter Nutzer wird in der Datenbank gespeichert */
$registrationSuccessful = $SchachfibelDAO->registerUser($username, $email, $password, $passwordRepeat, $update_path, $agb); ?>
</p>
</div>
<?php }else{
/*Wenn das Bild nicht hochgeladen wird, wird dem Nutzer Standardbild zugewiesen*/
$standardImage = 'php/images/standardImage.jpg';
if(!file_exists($standardImage)){ ?>
<div class="fehlerRegistration">
<p>
System Fehler: Das Bild kann nicht geladen werden!
</p>
</div>
<?php } else{ ?>
<div class="fehlerRegistration">
<p>
<?php $registrationSuccessful = $SchachfibelDAO->registerUser($username, $email, $password, $passwordRepeat, $standardImage, $agb);
}?>
</p>
</div>
<?php }
}else{ ?>
<div class="fehlerRegistration">
<p>
AGB bitte akzeptieren!
</p>
</div>
<?php }
/* Nach der erfolgreichen Registrierung wird auf die Anmeldeseite weitergeleitet */
if ($registrationSuccessful) {
echo "Registrierung war erfolgreich";
$url = "./anmelden.php";
echo ("<script>location.href='$url'</script>");
} else {?>
<div class="fehlerRegistration">
<p>
Registrierung war nicht erfolgreich;
</p>
</div>
<?php }
}
?>
</div>
<!--Sozial Media-->
<div class="right" id="sozial">
<div class="or">OR</div>
<button class="social-signin facebook" id="facebookNutzer">Mit Facebook anmelden</button>
<button class="social-signin twitter" id="twitterNutzer">Mit Twitter anmelden</button>
<button class="social-signin google" id="googleNutzer">Mit Google+ anmelden</button>
</div>
</div>
</div>
<script>
var my = document.getElementById("nutzerName");
var lowerCaseLetters = /[a-z]/g;
var upperCaseLetters = /[A-Z]/g;
function showHint(str) {
if(str.match(lowerCaseLetters) || str.match(upperCaseLetters) ||
str.value.length >= 4 && str.value.length < 11){
var xhttp;
if (str.length == 0) {
document.getElementById("ajax").innerHTML = "";
return;
}
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("ajax").innerHTML = this.responseText;
}
};
xhttp.open("GET", "./ajax.php?q=" + encodeURIComponent(str), true);
xhttp.send();
}
}
</script>
<?php include "php/footer.php"; ?>
hier ist registrierungsseite.
ich habe neue Aufgabe "Implementieren Sie eine datenschutzrechtlich einwandfreie Registrierung und Anmeldung! ".
könnte jemand mir sagen, was soll ich noch machen, damit diese Aufgabe erfüllt wird.
vielen Dank im Voraus.