How do I save information to a MySQL DB? (VaRest)

So I followed tutorials and I am able to receive information from my DB but I can’t find any tuts on saving info to that database. I am using VaRest. As an example I have a column for kills. I can call that from the db but I don’t know how to add +1 kill to the database once a player gets a kill. Thanks

You seem to lack of knolage about how HTTP communication work, you need to wrtie a script on HTTP server side that will +1 kill, insted sending GET send POST, i don’t know what setup you have but same as you did SELECT command you need to do UPDATE command some how like this:

UPDATE `players` SET `kills` = `kills` + 1 WHERE `ID` = '?????'

Read tutorials about MySQL and how to manage database by MySQL queries because this is how you edit the DB with your code. If you use php then try to ply with phpMyAdmin, it a database editor when you edit thing in it it shows MySQL commands which you can use. So besicly forget about UE4 for now and try to learn how to do MySQL things on HTTP server alone and how HTTP communication works. If you learn that doing things in UE4 will be easy you to understand

VaRest let you send parameter, so you will also need to know how to read on HTTP server side to read parameters you send.

Remember that UE4 server should communicate with HTTP server and HTTP server should listen only to UE4 server, aspecially when you edit data or else your setup will be very easy to hack

You’re right I’m super new to PHP. Your example makes perfect sense. I would then need to call the player ID which shouldn’t be to hard because it is already being loaded when the player logs in. However, what I am not sure of is what the rest of the code would look like.

<?php
include_once "dbscript.php";

?
?
?

$stmt = $conn->prepare("UPDATE players SET kills = ? WHERE username = ? ");
$stmt->bind_param("list", $kills, $username );
$stmt->execute();
$stmt->close();

?>

The question marks are what I am not sure about. Also I’m not sure this code is right. Does it look like I am on the right track?

EDIT: Here is my current code after some research.

<?php

include_once "dbscript.php";

$mydata = json_decode(file_get_contents('php://input'));
$username= $mydata ->username;
$kills= $mydata ->kills;
$wins= $mydata ->wins;

$stmt = $conn->prepare("UPDATE users SET kills = kills +1 , wins = wins +1 WHERE username = ?");
$stmt->bind_param("list", $kills, $wins, $username);
$stmt->execute();
$stmt->close();
echo json_encode(array('status'=>'OK', 'username'=>$username));



?>

EDIT2: I see I am not +1ing it. Will fix.

EDIT3: Fixed in second code

I didn’t used php for long time but it looks ok to me.

One note HTTP protocol already have status code, you probably seen things like error 404, 403 and 500 while browsing internet, this is HTTP status code which if first thing that HTTP server sends in response to request (this way browser and other software knows that they getting 404 regardless of how page is composed), if everything is ok HTTP send 200 OK. Lot of HTTP API solution ssend just status code and header without content as response because staus code alone is enought. So you dont need to send status and you dont need to send content at all if you want to be minimalistic, there ton of status codes that you not even knew about which can be used in APIs.

With php you have full control over what HTTP server sends, HTTP status code, HTTP headers and all the content. Thats why it ig you do any php coding it good to learn about HTTP

Not sure if VeRest plugin let you get status code of redponce.