Getting Username from login from

Thread Solved

Join Date: Oct 2007
Posts: 178
Reputation: lordx78 is an unknown quantity at this point 
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

Getting Username from login from

 
0
  #1
Feb 20th, 2008
After the user has inputted their respective username and password, it will be validates and if the submitted information was true, they will redirected a page. Now, I just want to the the php code that captures the username and display it on the page. Like "Welcome BooBoy08 to here..". Please help.
Last edited by lordx78; Feb 20th, 2008 at 11:43 am.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 514
Reputation: techniner is an unknown quantity at this point 
Solved Threads: 19
techniner techniner is offline Offline
Posting Pro

Re: Getting Username from login from

 
0
  #2
Feb 20th, 2008
Depends on your look up feature.

But general idea is:

  1. <?
  2. $user=$HTTP_SERVER_VARS["PHP_AUTH_USER"];
  3. ?>
  4. Welcome back <b> <?= $user ?>, We have missed you!
  5. <br><br>
Last edited by techniner; Feb 20th, 2008 at 12:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 178
Reputation: lordx78 is an unknown quantity at this point 
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

Re: Getting Username from login from

 
0
  #3
Feb 20th, 2008
It generates errors.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 6
Reputation: fenixZ is an unknown quantity at this point 
Solved Threads: 1
fenixZ fenixZ is offline Offline
Newbie Poster

Re: Getting Username from login from

 
0
  #4
Feb 20th, 2008
Why don't you put it in a session var??? And then display it with something like echo $var; ?? Don't worry about missing name if this var is empty so the user is not logged in.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Getting Username from login from

 
0
  #5
Feb 20th, 2008
When the user logs in, check if he's a valid user. If he's a valid user, add that username to a session variable. Use that session variable in the next page where you want to display his name. A small eg.
  1. <?php //page1.php
  2. session_start();
  3. // check if the user is valid
  4. if (valid user){
  5. $_SESSION['username']=$username;
  6. redirect to page2.php
  7. } else {
  8. //error message
  9. }
And this is page2.php
  1. <?php
  2. if(isset($_SESSION['username'])){
  3. echo "Welcome ". $_SESSION['username'];
  4. } else {
  5. echo "Not logged in ! ";
  6. exit;
  7. }

Hope that helps.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC