probleme enregistrement bdd
- Accueil
- Forum
- Programmation
- PHP
- probleme enregistrement bdd
fredloulou Le 2 octobre 2019 à 21:11 (Édité le 4 octobre 2019 à 02:29)
si quelqu'un peut m'aider voici le code
- <?php$username = "root";
$host = "localhost";
$dbname = "monsite";
$db = mysqli_connect($host, $username, $password, $dbname );
if (!$db) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
require 'openid.php';
$_STEAMAPI = "87BF36642E180E09F581A68F5E72DB9C";
try {
$openid = new LightOpenID('www.audiochat.xyz/index.php');
if(!$openid->mode) {
if(isset($_GET['login'])) {
$openid->identity = 'http://steamcommunity.com/openid/?l=english';
header('Location: ' . $openid->authUrl());
} else {
echo "<h2>Connect to Steam</h2>";
echo "<form action='?login' method='post'>";
echo "<input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>";
echo "</form>";
}
} 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);
$url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches";
$json_object= file_get_contents($url);
$json_decoded = json_decodemysql_select_db($json_object);
foreach ($json_decoded->response->players as $player)
{
$sql_fetch_id = "SELECT * FROM users_steam WHERE steamid = $player->steamid";
$query_id = mysqli_query($db, $sql_fetch_id);
$_SESSION['name'] = $player->personaname;
$_SESSION['steamid'] = $player->steamid;
$_SESSION['avatar'] = $player->avatar;
if (mysqli_num_rows($query_id) == 0) {
$sql_steam = "INSERT INTO users_steam (name, steamid, avatar) VALUES ('$player->personaname', '$player->steamid', '$player->avatar')";
mysqli_query($db, $sql_steam);
}
}
} else {
echo "User is not logged in.\n";
}
}
} catch(ErrorException $e) {
echo $e->getMessage();
}-
Profil introuvable Le 3 octobre 2019 à 14:46 (Édité le 1 janvier 1970 à 01:00)
Tu as déjà créer un topic sur Sitedudev pas la peine d'en recréer un autre sur d'autres sites...