Answer the question
In order to leave comments, you need to log in
How to make the separation of incoming information in the database through $_GET?
Goodnight! I'm struggling with a logical solution to a problem.
Data comes to the server that contains the HWID of the PC and information about it, sometimes the pcname field can be the same for two ownerid at the same time, how to make sure that each owner id receives data that came to him, and if the ownerid and pcname match, then just update the info field rather than creating a new one. I made this code, but got confused
$pcname = $_GET['a'];
$info = $_GET['str'];
$owner = $_GET['own'];
$stmt = $pdo->prepare("SELECT * FROM sloader ORDER BY pcname=?");
$stmt->execute([$pcname]);
$pcinfo = $stmt->fetch();
if ($pcinfo['ownerid'] != $owner && !$pcinfo['pcname']) { // если не существует
$sql = "INSERT INTO sloader (ownerid, pcname, info, dLink) VALUES (?,?,?,?)";
$pdo->prepare($sql)->execute([$owner, $pcname, $info , 0]);
$pdo = null;
} else {
$sql = "UPDATE sloader SET info=? WHERE pcname=?";
$stmt= $pdo->prepare($sql);
$stmt->execute([$info, $pcname ]);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question