Solved

Displaying Logged on User Names

Posted on 2004-08-02
3
210 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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.
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now