Jump to content

Getting specific user from database?


Zero767

Recommended Posts

Hey, I have my login script, and I have it setup so that if they are not logged in it shows the login box, and if they are, it shows a welcome message.  But how I can I get the specific username of the person who logged in, from the database?

 

Here is my code:

 

<?php
if (!isset($_SESSION['authenticated'])) {
echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"\">
        <label for=\"username\">Username:</label>
        <input type=\"text\" name=\"username\" id=\"username\" />
        <label for=\"textfield\">Password</label>
        <input type=\"password\" name=\"pwd\" id=\"pwd\" />
        <input name=\"login\" type=\"image\" src=\"images/login_button.jpg\" id=\"login\" value=\"Log in\" />
	</form>";
exit;
  }
echo "Hey, welcome back $username!";
?>

Link to comment
https://forums.phpfreaks.com/topic/44870-getting-specific-user-from-database/
Share on other sites

Ok, I figured out how to put the name there.  But, when I code it so they can change details about themselves, how to I know which user specificly is logged in?  Do I match the superglobal array I made for my session to match the username with the one in the databse then do an if statment from there?

 

Thanks.  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.