28, May 2012

say hello to a user - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: say hello to a user
« previous next »
Pages: [1] Print

Author Topic: say hello to a user  (Read 1801 times)
What a dork
*
Posts: 15
112 credits
Members referred : 0


« on: Apr 28, 2006, 08:09:06 am »

Dear Olaf,

in the access_user class, what's your opinion to say a Welcome to registered users in the scripts?
for example, in some pages i don't need to protection, i just wanna say a "Welcome" to users who have loged in. i use the following code, but i get some Warnings!

----header.php----
session_start();
function showheader1 () {           
if (isset($_SESSION['user'])) { // user has loged in
    $hello_name =  "Welcome ".$_SESSION['user']; }
echo($hello_name)." ";
--------

the warning i get:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output

started at D:\Program Files\Apache Group\Apache2\htdocs\index.php:1) in D:\Program Files\Apache

Group\Apache2\htdocs\header.php on line 3

best regards

Atabak.

p.s.  i use showheader function in the index.php script, as below:

----index.php------
include("/header.php");
showheader();
--------------
« Last Edit: Apr 28, 2006, 08:55:53 am by olaf »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Apr 28, 2006, 09:02:07 am »

Hello,

you have several problems in your solution:
1. don't output data to the browser if you send a header some rows later;)

there is a example how to show the user name after login iniside the example file: example.php, note the two rows containing:

Code:
$page_protect->get_user_info();
$hello_name = ($page_protect->user_full_name != "") ? $page_protect->user_full_name : $page_protect->user;


after using this code you can echo the variable $hello_name like:
Code:
echo "Hello ".$hello_name." !";

What a dork
*
Posts: 15
112 credits
Members referred : 0


« Reply #2 on: May 11, 2006, 02:47:14 pm »


Dear Olaf,
thanks for your reply.
this soloution is good only for the registered users that they have loged in before!
but in a website, we have visitors who have not loged in! (even not
registered)
so as a first step we should realize if a user has loged in.
what's your opinion as the best way, to check if a visitor has loged in or not!

then we will say Hello to the users who they have loged in to the website.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: May 11, 2006, 02:56:56 pm »


Dear Olaf,
thanks for your reply.
this soloution is good only for the registered users that they have loged in before!
but in a website, we have visitors who have not loged in! (even not
registered)
so as a first step we should realize if a user has loged in.
what's your opinion as the best way, to check if a visitor has loged in or not!

then we will say Hello to the users who they have loged in to the website.

maybe this simple test:
Code:
if (empty($_SESSION['user'])) echo "Hello stranger";

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2376
Tags : browsers Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: say hello to a user
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 10:42:15 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.