Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Displaying Logged on User Names

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Advice needed on CMS/coding platform 9 60
Set up Wildfly 10 8 419
HTML Editor to Choose? (2015) 13 83
Firewall vs WYSIWYG editor 5 81
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 connect a WordPress website to Google Analytics. 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 :…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

790 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