I just want to check if a value is in a table (key_list) and if it is true/the value is in the table (key_list) delete the value and insert an other value to an other table (player_list) if the value is already in the other table (player_list) then it shouldn't insert the value.
Here goes my code:
<!DOCTYPE html>
<head>
<lang
="en">
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<link href="assets/css/main-css.css" rel="stylesheet">
<script src="assets/js/sweetalert2.min.js"></script>
<script srt="assets/js/jquery-3.5.1.js"></script>
<meta charset="UTF-8">
<link rel="shortcut icon" href="assets/img/icon.png">
<title>BuzzGames | BetaKey</title>
</head>
<body>
<form method="POST" action="signup.php">
<input type="text" name="name" placeholder="dein Minecraft-Name">
<br>
<input type="text" name="key" placeholder="dein Betakey">
<br>
<input type="submit">
</form>
</body>
<?php
$name = $_POST['name'];
$key = $_POST['key'];
$host = "localhost";
$user = "system";
$password = "";
$db = "buzzgames_betakey";
$cxn = mysqli_connect($host, $user, $password, $db);
$qryPlayerGet = mysqli_query($cxn, "SELECT * FROM player_list WHERE username = ('$name')");
$qryPlayerAdd = mysqli_query($cxn,"INSERT INTO player_list('username') VALUES ('$name')");
$qryKeyGet = mysqli_query($cxn,"SELECT * FROM key_list WHERE betakey = '$key'");
$qryKeyRemove = mysqli_query($cxn,"DELETE * FROM key_list WHERE betakey = '$key'");
if (!mysqli_query($cxn, $qryPlayerGet)) {
mysqli_query($cxn, $qryPlayerAdd);
}
if (!mysqli_query($cxn, $qryKeyGet)) {
mysqli_query($cxn, $qryKeyRemove);
}
header("Location: index.php");
?>