2026-03-09 07:12:13 +01:00

35 lines
1.1 KiB
PHP

<?php
// include database and object files
include_once '../config/init.php'; // contains $db
include_once '../objects/db_user.php';
include_once '../config/error.php';
// prepare user object
$user = new User($db);
// ensure userId is passed in $_POST parameters
if (isset($_POST['userId']))
$user->id = (int)$_POST['userId'];
else trigger_error( missing_parameter_error("userId") );
// load all info for this user id
if ($user->load())
{
// then update fields with the passed information (and update last connection time)
$user->firstName = $_POST['firstName'];
$user->lastName = $_POST['lastName'];
$user->leftHanded = (strcasecmp( $_POST['leftHanded'], "true" ) == 0) ? 1 : 0;
$user->maleGender = (strcasecmp( $_POST['maleGender'], "true" ) == 0) ? 1 : 0;
$user->charSkinAssetName = $_POST['charSkinAssetName'];
$user->weaponAssetName = $_POST['weaponAssetName'];
$user->size = (int)$_POST['size'];
if ($user->update())
{
$user_arr = $user->getResultArray(true, "User_Info_Updated");
print_r(json_encode($user_arr)); // OK
}
else trigger_error("Error_Retrieving_User_Info");
}
else trigger_error("Unknown_User_ID");
?>