fixed invalid register username problems
This commit is contained in:
parent
2a3f639a66
commit
888c7a5019
13
index.php
13
index.php
@ -66,12 +66,23 @@ session_start();
|
|||||||
|
|
||||||
if (str_starts_with($_POST["sub"], "Registrovat"))
|
if (str_starts_with($_POST["sub"], "Registrovat"))
|
||||||
{
|
{
|
||||||
|
$failed = false;
|
||||||
|
|
||||||
$database -> query("INSERT INTO user_info (nickname) VALUES (\"" . $safe_uname . "\")");
|
$database -> query("INSERT INTO user_info (nickname) VALUES (\"" . $safe_uname . "\")");
|
||||||
$key_id_out = $database -> query("SELECT id FROM user_info WHERE nickname=\"" . $safe_uname . "\"");
|
$key_id_out = $database -> query("SELECT id FROM user_info WHERE nickname=\"" . $safe_uname . "\"");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
$database -> query("INSERT INTO user (username, password, user_info) VALUES (\"" . $safe_uname . "\",\"" . $hashed_pass ."\", " . ($key_id_out -> fetch_assoc())["id"] . ")");
|
$database -> query("INSERT INTO user (username, password, user_info) VALUES (\"" . $safe_uname . "\",\"" . $hashed_pass ."\", " . ($key_id_out -> fetch_assoc())["id"] . ")");
|
||||||
|
} catch (mysqli_sql_exception $e)
|
||||||
|
{
|
||||||
|
$failed = true;
|
||||||
|
$database -> query("DELETE FROM user_info WHERE nickname=\"" . $safe_uname . "\"");
|
||||||
|
|
||||||
login($safe_uname);
|
echo "<script>alert(\"Při registraci došlo k chybě.\\n\\nZkontrolujte, zda-li Vaše uživatelské jmeno neobsahuje speciální znaky a zkuste to znovu.\");</script>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$failed) login($safe_uname);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$res = $database -> query("SELECT username, password FROM user WHERE BINARY username=\"" . $safe_uname . "\" AND BINARY password = \"" . $hashed_pass . "\"");
|
$res = $database -> query("SELECT username, password FROM user WHERE BINARY username=\"" . $safe_uname . "\" AND BINARY password = \"" . $hashed_pass . "\"");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user