Solved

Displaying Logged on User Names

Posted on 2004-08-02
3
216 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
[X]
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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
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 add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to Import and export files in 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 : Click on Too…

749 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