Post: [PHP Help] Calling a users name that is logged in?
08-22-2013, 03:58 AM #1
Dan
I'm a god.
(adsbygoogle = window.adsbygoogle || []).push({}); I'm trying to get it to say "Welcome, (User's name)!". But I don't know how to call it..

I figured this out, all I had to do was on the login page I set a $_SESSION['username'] = $username; and then I called it on the index.

    
<?php
session_start();
error_reporting(0);

if($_SESSION['login'] == 1)
{
?>
<html>
page content
</html>
<?php
} else {
?>
<html>
if not logged in content
</html>
<?php
}
?>
Last edited by Dan ; 08-23-2013 at 05:40 PM.
08-22-2013, 04:17 AM #2
bman242
I am error
for what are you gunna use this for tho
08-24-2013, 02:01 PM #3
Default Avatar
Oneup
Guest
Originally posted by Dan View Post
I'm trying to get it to say "Welcome, (User's name)!". But I don't know how to call it..

I figured this out, all I had to do was on the login page I set a $_SESSION['username'] = $username; and then I called it on the index.

    
<?php
session_start();
error_reporting(0);

if($_SESSION['login'] == 1)
{
?>
<html>
page content
</html>
<?php
} else {
?>
<html>
if not logged in content
</html>
<?php
}
?>


It's usually best to use the userID for the session rather then the user name. That's so if you are ever doing any lookups you can make sure that you are always pulling the right records.
09-10-2013, 01:27 PM #4
KLArcher
Little One
Bro add me on skype mapmonkiesmodz, irl give you my login system.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo