Solved

Displaying Logged on User Names

Posted on 2004-08-02
3
214 Views
Last Modified: 2010-04-07
I am creating a small chat room using PHP, MySQL & Dreamweaver.  Everything is great apart from one problem that I can't seem to find the answer.

The first page of the site is a login screen, which obviously only allows registered users to enter the chat room.  A successfull login moves the user to page 2, which is the Chat Room.  I would like to now how to;

Display the users name in a header bar in the chatroom, so that I can add a welcome message.

Autocomplete the username field of the database when the users posts a message.  This is to save them having to type in their name every time they post.

Also, how do I refresh the page so that if the users doesn't post a message it still updates when other users post theirs.

Any help would be much appreciated.

Thanks

Housey
0
Comment
Question by:Housey
  • 2
3 Comments
 
LVL 10

Expert Comment

by:rockmansattic
ID: 11692794
Pretty easy..

1) you can display the logged in username using php like this:
<?php echo $_SESSION['MM_Username'];?>
You can put this code anywhere you want to show the logged in username.  

2)Have a hidden field in the 'post a message' form like this:
<input name="username" type="hidden" value="<?php echo $_SESSION['MM_Username'];?>">
use this hidden field as the username in the post.

3) The easiset  way is like this using the meta tag
<head><meta http-equiv="refresh" content="10"></head>

rockman
0
 
LVL 1

Accepted Solution

by:
C7Swill earned 150 total points
ID: 11824627
Put:
<?
session_start();
?>

At the top of all the pages you need to have this persistent username.

on successfull login, convert their username to a session.

i.e.:

$_SESSION['displayname'] = $_POST['username'];

Then to display it, you would:

echo $_SESSION['displayname'];
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12007195
Has your question been answered?

Rockman
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question