bugfix in rename.php

This commit is contained in:
Leander
2017-04-30 17:20:23 +02:00
parent e93191689d
commit 16e21d8114
3 changed files with 6 additions and 1 deletions

View File

@@ -26,6 +26,7 @@
14101 - User name doesn't match rules
14102 - User ID not specified
14103 - User name already exists
14104 - User ID not existing
= highscores.php =
15101 - User ID not specified

View File

@@ -73,9 +73,10 @@ class Database
case 12103:
return 'Sorry, we only have '.$values[0].' questions. Please try again.';
case 12104:
case 14104:
case 15102:
case 16102:
return 'The specified user name does not exist. This is an internal error.';
return 'The specified user ID does not exist. This is an internal error.';
case 13102:
return 'No valid time specified. This is an internal error.';
case 13103:

View File

@@ -18,6 +18,9 @@ if(preg_match(PATTERN, $name) != 1) {
$error = 14101;
} else if($uid == '') {
$error = 14102;
} else if($db->query('SELECT EXISTS (SELECT 1 FROM "Users" WHERE "ID" = $1)', array($uid))
['data'][0]['exists'] == 'f') {
$error = 14104;
} else {
$db->query('UPDATE "Users" SET "name" = $1 WHERE "ID" = $2', array($name, $uid));
if(preg_match('/violates unique constraint "Users_name_unique"/', pg_last_error()) == 1) {