I want to check if the $steamprofile['steamid']
already exists, to prevent multiple entries.
The SteamID64 looks like: 76561197968052866
and is stored in bigint(64).
Thats my code so far:
$db = mysqli_connect($servername,$username,$password,$dbname) or die ("could not connect to database");
$user_check_steamid = "SELECT * FROM Users WHERE SteamID64";
$result = mysqli_query($db, $user_check_steamid);
$user = mysqli_fetch_assoc($result);
if($user) {
if($user['SteamID64'] === $steamprofile['steamid']){
//Update username
//code don't exists right now
echo "update username";
} else {
//Create new account in database
//$sql = "INSERT INTO Users (SteamID64, Username) VALUES ('" . $steamprofile['steamid'] . "', '" . $steamprofile['personaname'] . "')";
//if ($db->query($sql) === TRUE) { }
echo "creating user";
}}
I don't want to use a primary key.
Do you have any ideas, what I did wrong or how I can improve it?`