Adding input validation before saving to the db (#105)

This commit is contained in:
lslschr
2024-02-10 13:58:31 +01:00
committed by GitHub
parent 05f9332fb8
commit 048bf2d0aa
6 changed files with 60 additions and 16 deletions
+10 -2
View File
@@ -8,6 +8,14 @@ require_once 'includes/i18n/' . $lang . '.php';
require_once 'includes/version.php';
function validate($value) {
$value = trim($value);
$value = stripslashes($value);
$value = htmlspecialchars($value);
$value = htmlentities($value);
return $value;
}
if ($userCount > 0) {
header("Location: login.php");
exit();
@@ -29,8 +37,8 @@ while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
$passwordMismatch = false;
$registrationFailed = false;
if (isset($_POST['username'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$username = validate($_POST['username']);
$email = validate($_POST['email']);
$password = $_POST['password'];
$confirm_password = $_POST['confirm_password'];
$main_currency = $_POST['main_currency'];