Jump to content


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


Personal touch to site

Recommended Posts

Hi All,

Hope somebody can help... the problem is that i have created a log in page for my site using dreamweaver MX and php mysql everything works fine but i would like to display the firstname and surname of the user that has logged in on the next page. My database is set up that the username and password fields are in the same table as the data i want to display if you will


if you can understand what i mean i would appriciate some help!!!!

Share this post

Link to post
Share on other sites
welcome to the forums! hope we can help you out here.

if i understand what you're after, once someone successfully logs it, you ought to keep a session variable with their user_id (or even just their username) so that you can pull their information on any future pages they hit. once you do that, you can run a simple query at the top of the page pulling their information from the database. use it wherever you want on the rest of the page.

Share this post

Link to post
Share on other sites
Well first off every page in your site needs to start with
Even the login page. After they fill in there username and password, and are authenticated you store the username in a session. Here is some code I use once the user has entered his info

$username = $_POST['username'];
$password = md5($_POST['password']);
$getuser = "SELECT * from users WHERE username = '$username' AND password = '$password'";
  $result = mysql_query($getuser) or die (mysql_error());
    $r = mysql_fetch_array($result);
    $qualify = mysql_num_rows($result);
if($qualify > 0){
$_SESSION['username'] = $_POST['username'];

Now whenever you want to use the persons username you just reference the session id

[code] echo "Hello $_SESSION['username'] welcome to my site";[/code]


Share this post

Link to post
Share on other sites


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.