I have a problem with the Steam Authentication for the web. As you know, Steam provides a script to allow people to connect on your site through the Steam database. My problem is my code only inserts the Steam ID in the database and not the name & avatar. My code:
if (isset($_GET['login'])){
require 'db.php';
require 'openid.php';
require 'userInfo.php';
try {
require 'SteamConfig.php';
$openid = new LightOpenID($steamauth['domainname']);
if(!$openid->mode) {
$openid->identity = 'http://steamcommunity.com/openid';
header('Location: ' . $openid->authUrl());
} elseif ($openid->mode == 'cancel') {
echo 'User has canceled authentication!';
} else {
if($openid->validate()) {
$id = $openid->identity;
$ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";
preg_match($ptn, $id, $matches);
$_SESSION['steamid'] = $matches[1];
$sql_fetch_id = "SELECT * FROM member WHERE steamid = '".$_SESSION['steamid']."'";
$query_id = mysqli_query($db, $sql_fetch_id);
if (mysqli_num_rows($query_id) == 0) {
$sql_steam = "INSERT INTO member (name, steamid, avatar) VALUES ('".$_SESSION['personaname']."', '".$_SESSION['steamid']."', '".$_SESSION['avatar']."')";
mysqli_query($db, $sql_steam);
}
if (!headers_sent()) {
header('Location: '.$steamauth['loginpage']);
exit;
} else {
?>
<script type="text/javascript">
window.location.href="<?=$steamauth['loginpage']?>";
</script>
<noscript>
<meta http- equiv="refresh" content="0;url=<?=$steamauth['loginpage']?>" />
</noscript>
<?php
exit;
}
} else {
echo "User is not logged in.
";
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}
}