Devfren Posted December 16, 2021 Share Posted December 16, 2021 Bonjour, je suis nouveau sur le forum et j'aimerais avoir votre aide. Mon problème est le suivant. J'ai créé un espace membres sur mon site Web et je souhaite que chaque utilisateur connecté puisse voir combien de points ils ont à disposition. J'aimerais donc l'appeler à partir de ma base de données et afficher chaque utilisateur individuellement en fonction de sa session. Merci d'avoir lu j'aimerais beaucoup Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/ Share on other sites More sharing options...
gw1500se Posted December 16, 2021 Share Posted December 16, 2021 This is an English forum and you have already posted this question. Such as it is. Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/#findComment-1592774 Share on other sites More sharing options...
Barand Posted December 16, 2021 Share Posted December 16, 2021 When they log in, store their userID as a session variable. When you want to display their points, query your database using that userID. Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/#findComment-1592775 Share on other sites More sharing options...
Devfren Posted December 16, 2021 Author Share Posted December 16, 2021 i just want an example because i have already tried but still the errors Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/#findComment-1592776 Share on other sites More sharing options...
ginerjm Posted December 16, 2021 Share Posted December 16, 2021 Show us your code where the errors are happening. Show us the error messages too. Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/#findComment-1592777 Share on other sites More sharing options...
Barand Posted December 16, 2021 Share Posted December 16, 2021 1 hour ago, Devfren said: i just want an example Store id if login successful if (password_verify($_POST['password'], $row['password'])) { $_SESSION['user_id'] = $_POST['user_id']; } else { // error - invalid login } Get and display points if (isset($_SESSION['user_id'])) { $res = $conn->prepare("SELECT points FROM user_points WHERE user_id = ? "); $res->execute([${SESSION['user_id']}]); echo "You have " . $res->fetchColumn(). " points<br>"; } else { header("Location: login.php"); // send to login page } Quote Link to comment https://forums.phpfreaks.com/topic/314324-members-area-in-php-and-database/#findComment-1592779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.