Capturing username and displaying on another page

Reply

Join Date: Jul 2008
Posts: 9
Reputation: mirainc is an unknown quantity at this point 
Solved Threads: 0
mirainc mirainc is offline Offline
Newbie Poster

Capturing username and displaying on another page

 
0
  #1
Jan 14th, 2009
Hey all
How can i capture the username, which is being input in a textbox, and pass it to another page?

Login.php
Example,
username: admin

Welcome.php
it should display,
Welcome, admin

How can i achieve this?

Using dtreamweaver with PHP language

Thanks
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 81
Reputation: it2051229 is an unknown quantity at this point 
Solved Threads: 1
it2051229 it2051229 is offline Offline
Junior Poster in Training

Re: Capturing username and displaying on another page

 
0
  #2
Jan 14th, 2009
you pass it via the $_GET method or the $_POST method.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 9
Reputation: mirainc is an unknown quantity at this point 
Solved Threads: 0
mirainc mirainc is offline Offline
Newbie Poster

Re: Capturing username and displaying on another page

 
0
  #3
Jan 14th, 2009
Originally Posted by it2051229 View Post
you pass it via the $_GET method or the $_POST method.
Could you guide me on how to do that?
Im a beginner in php
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: Capturing username and displaying on another page

 
0
  #4
Jan 14th, 2009
Ok, you need to look at a few tutorials (there's millions on the net) about user logins and sessions. In a nutshell:

form.html This contains the textbox.
  1. <form action="submit.php" method="GET"> <!--or "POST"-->
  2. <input type="text" name="username" />
  3. </form>

submit.php Set the session variable
  1. <?php
  2. session_start(); //so you can use the session variable
  3. &username = $_GET['username']; //or $_POST depending on form method
  4. echo "Hello $username. I have learnt your name!";
  5. SESSION['username']=$username;
  6. ?>
  7. <a href="/page.php">Return</a>

page.php //Content page
  1. <?php
  2. start_session();
  3. if isset($_SESSION['username']){
  4. echo "Hey $_SESSION['username'], I remembered your name!";
  5. }
  6. ?>
  7. ...rest of page content

Now please do some research so you understand that code and how your using it.

[code untested]
"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  
Reply

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



Other Threads in the PHP Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC