Page 1 of 1

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

Posted: Sat Aug 14, 2004 10:26 am
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 ?

Posted: Sat Aug 14, 2004 10:50 am
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.

Posted: Sat Aug 14, 2004 11:22 am
by Getran
:roll:

You are 1337 :P thanks man

[SOLVED]

Posted: Sat Aug 14, 2004 6:09 pm
by d3ad1ysp0rk
and to actually answer your question.. check your capitilization ;)