Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Jeff13246

  • Rank
  1. Like I said I'm completely new to PHP haha. I've been learning the basics through instructional guides and I'm completely stuck on how I can make this work. If you can give a brief explanation of where to go next, it would be a lot of help!
  2. If I assign only one of the users as having a value of 1 for the premium row, the image: "../../img/premium.png" appears on each users profile. I want this image to appear only on the users profile's who has the 'premium' row set as 1. I attached a picture of the user who has the specified row set as 1 if it helps to see. If I set it as 0, then the image "../../img/swiftify.png" appears on every users profile. Also if it helps, when I var_dump($user) I get object(stdClass)#3 (5) { ["idUsers"]=> string(1) "1" ["uidUsers"]=> string(11) "beanbean123" ["emailUsers"]=> string(20) "jeffgee999@gmail.com" ["pwdUsers"]=> string(60) "$2y$10$VzYSkM7PoVTEzcY9rCnBXejCCMp0kAaXnSa630sBuXWkx/jqh6NSG" ["premium"]=> string(1) "1" }
  3. Completely new to PHP here, so on my website I'd like a specific image to appear according to whether or not the user in my DB has a row called 'premium', with a value of 1. I've tried figuring it out on my own but I'm stuck. I watched a video of someone doing something similar so this is what I have currently, but I'm aware it's totally incorrect. //init.php file <?php if (session_status() == PHP_SESSION_NONE) {//php >5.4 session_start(); } $_SESSION['user_id'] = 1; $db = new PDO('mysql:host=;dbname=loginsystem', 'root', ''); $userQuery = $db->prepare(" SELECT idUsers, uidUsers, emailUsers, pwdUsers, premium FROM users WHERE idUsers =:user_id "); $userQuery->execute(['user_id' => $_SESSION['user_id']]); $user = $userQuery->fetchObject(); //webpage in which the image will appear <?php require_once '../includes/init.php'; ?> <?php if($user-> premium): ?> <img src="../../img/premium.png" alt="Swiftify+"></a> <?php else: ?> <img src="../../img/swiftify.png" alt="Swiftify+"></a> <?php endif; ?>
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.