-3
<?php
    include("db.php");
    $result = mysql_query("SELECT * FROM p_reg ");  
?>

The issue I am having is that I have a link in the navigation bar called 'User Profile'. This link should fetch a list of all the current users in the database but i only need personal profile of login user.

codeMagic
  • 44,549
  • 13
  • 77
  • 93

2 Answers2

0

Welcome to Stack Overflow. I would recommend reading this article on asking a question.

As to your question, I assume you have already implemented a login system for your users. If so, you should have the user's id in a $_SESSION variable or a $_COOKIE variable. There is much documentation on accessing these variables on the PHP website. You can use this id to get the right user on the profile page.

Community
  • 1
  • 1
Ramsay Smith
  • 1,098
  • 13
  • 30
0

Change your SQL query so that it only selects the profile of a certain user. For example if you know the user's email and it is stored in the database:

SELECT * FROM p_reg WHERE email='userEmailAddress@email.com'
Remus Grigorescu
  • 43
  • 1
  • 1
  • 7