$value) {
if (($data[$key] = filter($value)) === false) {
print_r($value);
echo "Failed to sanitize: `" . $key . "`: " . $value . " \t-\t type: " . gettype($value) . "\n";
}
}
$userEmail = $data['newEmail'];
$userPass = $data['newPassword'];
$userName = $data['newName'] ?? '';
if(strlen($userPass) < 6){
$err[] = "Password is too short. Password needs to be at least 6 characters!";
}
else if(strlen($userPass) > 30){
$err[] = "Password is too long. Max length is set to 30 characters. If you believe it should be higher please contact the developers.";
}
if(strlen($userEmail) > 220){
$err[] = "Your email-address is too long. Can you please register with another email?";
}
if(strlen($userName) > 200){
$err[] = "Your name seems to be too large to fit this system. Maybe you can short it somehow?";
}
if(empty($err)){
// HASH PASSWORD
$newPass = PwdGen($userPass, true);
$createUserSQL = "INSERT INTO user SET full_name = '$userName', user_email = '$userEmail', pwd = '$newPass';";
if($db->query($createUserSQL)){
$newID = $db->insert_id;
$updateUserSQL = "UPDATE user SET md5_id = '".md5($newID)."' WHERE user_id = '$newID';";
$db->query($updateUserSQL);
header("Location: login.php?thank");
}
else {
$err[] = "Something went wrong:
".$db->error;
}
}
}
?>