so I am currently making a site where it needs to connect to my database when they login. on login, it retrieves the users ID. But I got the code working, no errors, but when I looked in my database, it got a random number for the ID and stored that. So what am I doing wrong?
<?php
require 'steamauth/steamauth.php';
if(!isset($_SESSION['steamid'])) {
$username = "Unknown";
$avatar = "defaultUser";
$accid = "Unknown";
$avatarSmall = "smallUser"; //For Dashboard
} else {
include ('steamauth/userInfo.php');
$username = &$steamprofile['personaname'];
$avatar = &$steamprofile['avatarmedium'];
$accid = &$steamprofile['steamid'];
$avatarSmall = &$steamprofile['avatar']; //For Dashboard
include('connect-mysql.php');
if(!$dbcon){
die('Database Failed To Connect.');
}else{
$checkUserID = mysqli_query($dbcon, "SELECT userID from userData WHERE userID = '&$accid'");
if(!$checkUserID){
die('Server Failed To Respond.');
}else{
if(mysqli_num_rows($checkUserID) > 0) {
$getCredits =mysqli_query($dbcon, "SELECT userCredits from userData WHERE userID = '&$accid'");
}else{
$sqlinsert = "INSERT INTO userData (userID, userCredits) VALUES ('&$accid', '0')";
if(!mysqli_query($dbcon, $sqlinsert)){
die('Server Failed To Respond To Query.');
}
}
}
}
}
?>
But its strange because when I use $accid in my html code, it displays the correct number.
Any ideas?
Thanks,
Matt