FabrikaHradekTour/res/forum/api/update_user.php

23 lines
912 B
PHP
Raw Normal View History

2024-05-22 17:20:11 +02:00
<?php
include("../../global.php");
session_start();
if (!isset($_SESSION["username"])) goto fail;
$out = $database -> query("SELECT username, admin, user_info FROM user WHERE BINARY username=\"" . $_SESSION["username"] . "\" AND admin=\"1\"");
if (!isset($_GET["old_username"])) return;
if ($out -> num_rows != 1 && $_GET["old_username"] != $_SESSION["username"])
{
fail:
echo "nope";
header("Location: ../../../index.php");
return;
}
$user_info_id = (($database -> query("SELECT user_info FROM user WHERE username=\"" . $_GET["old_username"] . "\"")) -> fetch_assoc())["user_info"];
$database -> query("UPDATE user SET username=\"" . $_GET["username"] . "\", admin=" . $_GET["admin"] . " WHERE user_info=" . $user_info_id);
$database -> query("UPDATE user_info SET sex=" . $_GET["sex"] . ", bio=\"" . $_GET["bio"] . "\", nickname=\"" . $_GET["nickname"] . "\" WHERE id=" . $user_info_id);