[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Displaying Logged on User Names

Posted on 2004-08-02
3
Medium Priority
?
229 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 450 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

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…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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