<? echo $myusername ; ?>

Reply

Join Date: Mar 2009
Posts: 3
Reputation: london77 is an unknown quantity at this point 
Solved Threads: 0
london77 london77 is offline Offline
Newbie Poster

<? echo $myusername ; ?>

 
0
  #1
Mar 18th, 2009
hii there..

im have created a user login page with php and mysql.
but somehow im having problem when i try to show username information after user login.

i have put this code

<? echo $myusername ; ?>

but it doesnt show the username..

what can be the problem?

thnks in advance..
Last edited by london77; Mar 18th, 2009 at 5:55 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: <? echo $myusername ; ?>

 
0
  #2
Mar 18th, 2009
does $myusername have a value?

you are using shorttags "<?", does your server allow them?
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: london77 is an unknown quantity at this point 
Solved Threads: 0
london77 london77 is offline Offline
Newbie Poster

Re: <? echo $myusername ; ?>

 
0
  #3
Mar 18th, 2009
Originally Posted by kkeith29 View Post
does $myusername have a value?

you are using shorttags "<?", does your server allow them?

hii thanks for reply..

yeah it allows "<?"

and i actually used this code

<? echo $_SESSION['myusername']; ?>

but it didnt work too ..
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: <? echo $myusername ; ?>

 
0
  #4
Mar 18th, 2009
can you post your code? i can't do much more without seeing how you coded it.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 3
Reputation: london77 is an unknown quantity at this point 
Solved Threads: 0
london77 london77 is offline Offline
Newbie Poster

Re: <? echo $myusername ; ?>

 
0
  #5
Mar 18th, 2009
Originally Posted by kkeith29 View Post
can you post your code? i can't do much more without seeing how you coded it.

thnks again...

somehow it worked now..

didint even change anything..

weird..
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 93
Reputation: humbug is an unknown quantity at this point 
Solved Threads: 13
humbug's Avatar
humbug humbug is offline Offline
Junior Poster in Training

Re: <? echo $myusername ; ?>

 
0
  #6
Mar 18th, 2009
a variable (such as $myusername ) must be set in the same script for it to have a value, and thus be echo'd to the page. This means the value will be lost if the user refreshes the or follows a link.

The $_SESSION is a special array that will hold it's value for a user until they close their browser. This means when they log in you must set the session variable:
  1. $_SESSION['myusername'] = "humbug"
Only after you have done that can you retrieve the value of the variable like you did with your echo $_SESSION['myusername']; statement.

Hope that clarified things.
"If your not having fun, your doing something wrong." - Humbug
★ Did I help you out? Did I piss you off? Add to my reputation!
The Gabriel Method is a great book for losing weight and keeping healthy - I know Jon Gabriel Personally.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 28
Reputation: nathenastle is an unknown quantity at this point 
Solved Threads: 2
nathenastle's Avatar
nathenastle nathenastle is offline Offline
Light Poster

Re: <? echo $myusername ; ?>

 
0
  #7
Mar 24th, 2009
hi this is nathen,
i think this is usefull to you some how,
you first start the session on top first page and the page which you want to show your username.In first page its self you should use $_Post['myusername']=$_SESSION['myusername'];
and you use $_SESSION['myusername'] in your second page where you want to show that value..
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,227
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 167
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: <? echo $myusername ; ?>

 
0
  #8
Mar 24th, 2009
Originally Posted by nathenastle View Post
hi this is nathen,
i think this is usefull to you some how,
you first start the session on top first page and the page which you want to show your username.In first page its self you should use $_Post['myusername']=$_SESSION['myusername'];
and you use $_SESSION['myusername'] in your second page where you want to show that value..
it would be $_SESSION['myusername'] = $_POST['myusername'] . you switched them around. there also would need to be some sanitation to prevent xss attacks.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 414 | Replies: 7
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC