slj90 Posted December 15, 2009 Share Posted December 15, 2009 Hello, I am trying to create a page that shows the users details, the code gets these details by finding the username in the table and then displaying the other details, but i can't really get my head around how to get this to work.. I have a session: <?php session_start(); // Check if we have an authenticated user if (!isset($_SESSION["authenticatedUser"])) //if not re-direct to login page { $_SESSION["message"] = "Please Login"; header("Location: loginform.php"); } else { //If authenticated then display page conetents ?> And then the code I am using (which doesn't work) to get the other info by using the username stored in authenticatedUser <?php include ("connectionusers.php"); // (2)gather details of username sent $Username = $_GET['authenticatedUser'] ; // (3)create query $query = "SELECT * FROM users WHERE authenticatedUser = $Username"; // (4) Run the query on the customer table through the connection $result = mysql_query ($query); // (5) print message with ID of inserted record if ($row = mysql_fetch_array($result)) { print "Your account details:<br>"; print "<br><b>You are member number...</b>" . $row["ID"] . "<br>" ; print "<br><b>Username: </b>" . $row["Username"] . "<br>"; print "<br><b>Email: </b>" . $row["Email"] . "<br>"; print "<br><b>Password: </b>" . $row["Password"] . "<br>"; } ?> I hope you understand what I am trying to do here and would appreciate any help you can give. Thanks! Link to comment https://forums.phpfreaks.com/topic/185272-getting-data-linked-to-user/ Share on other sites More sharing options...
teamatomic Posted December 15, 2009 Share Posted December 15, 2009 If the username is stored in a session why are you using a GET instead of SESSION? Link to comment https://forums.phpfreaks.com/topic/185272-getting-data-linked-to-user/#findComment-978117 Share on other sites More sharing options...
slj90 Posted December 16, 2009 Author Share Posted December 16, 2009 So your saying it should be.. <?php include ("connectionusers.php"); // (2)gather details of CustomerID sent $Username = $_SESSION["authenticatedUser"] ; // (3)create query $query = "SELECT * FROM users WHERE authenticatedUser = $Username"; // (4) Run the query on the customer table through the connection $result = mysql_query ($query); // (5) print message with ID of inserted record if ($row = mysql_fetch_array($result)) { print "Your account details:<br>"; print "<br><b>You are member number...</b>" . $row["ID"] . "<br>" ; print "<br><b>Username: </b>" . $row["Username"] . "<br>"; print "<br><b>Email: </b>" . $row["Email"] . "<br>"; print "<br><b>Password: </b>" . $row["Password"] . "<br>"; } ?> It still doesn't work. In the query line.. $query = "SELECT * FROM users WHERE authenticatedUser = $Username"; do I have the authenticatedUser and Username the right way round? Thanks Link to comment https://forums.phpfreaks.com/topic/185272-getting-data-linked-to-user/#findComment-978457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.