[SOLVED] My username function won't work (newb needing help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

[SOLVED] My username function won't work (newb needing help

Post by Getran »

i've setup a user system, but i have a page called portal.php. I can't get the $user var from login.php to appear onto the portal page (i'm a newb :P). Maybe i could make a function like setUser($user), which i've tried (but i'm not good with functions). I made the function like this:

on my 'process_login.php' page i had setUsername($user);

i set the function up like this:

Code: Select all

function setUsername($x) {
$showuser = $x;
return $showuser;
}
and to try to echo the username on the portal page i put setUsername()

but it didn't work, and i got this error:
Fatal error: Call to undefined function: setusername() in *hidden*\portal.php on line 25

can somebody help me with this ?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you can pass the username through sessions, or through the database in a session like table..

call [php_man]session_start[/php_man]() on all pages (at the top of the page) you want to access the session data. you can access the session data through the $_SESSION superglobal. So to set the username in the session:

Code: Select all

$_SESSION['username'] = $username;
and to retrieve it:

Code: Select all

$username = $_SESSION['username'];
read [php_man]sessions[/php_man] for more details about sessions from the php manual.
Getran
Forum Commoner
Posts: 59
Joined: Wed Aug 11, 2004 7:58 am
Location: UK
Contact:

Post by Getran »

:roll:

You are 1337 :P thanks man

[SOLVED]
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

and to actually answer your question.. check your capitilization ;)
Post Reply