Welcome visitor
* Login
* Register
It is currently February 22nd, 2020, 10:54 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP

Post new topic Reply to topic  [ 3 posts ] 
Author Message
  persistent variable
PostPosted: April 22nd, 2009, 10:29 pm 

Posts: 48
hey, im just using php to validate username and password, now i wish to show the name of the user on the top of all the pages inside the site. How can i do this? Keep in mind that i want to keep everything as much html as possible, thanks.

  Re: basic php question
PostPosted: April 22nd, 2009, 11:29 pm 
User avatar

Posts: 112
write your html document as you usally would.
on the space where you want to include the user name do something like this.
(and remember to save your file as php).
Username: <?php echo $_POST['username']; ?>

  Re: persistent variable
PostPosted: October 6th, 2009, 11:18 pm 
Site Admin
User avatar

Posts: 39
You can store the name inside a session variable.

To use session variables, all your (PHP) pages must begin with the session_start() statement. This way, the server will know you are using a session to store such variables.

Once the session is declared, you can store and recall the session variables in a way similar to regular variables.

Here's an example:


$_SESSION['name'] = 'John Doe';

echo $_SESSION['name'];

So as long as you declare your session_start() at the beginning of each page, your session variables will be available to use.

At log-off, you can use session_destroy() to ensure the session "memory" is erased from the server.

I'm not afraid to die. I just don't want to be there when it happens.
- Woody Allen

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

FORUMS » Server Side » PHP

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: