943,650 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 959
  • PHP RSS
Jan 14th, 2009
0

Capturing username and displaying on another page

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mirainc is offline Offline
9 posts
since Jul 2008
Jan 14th, 2009
0

Re: Capturing username and displaying on another page

you pass it via the $_GET method or the $_POST method.
Reputation Points: 7
Solved Threads: 1
Junior Poster in Training
it2051229 is offline Offline
82 posts
since May 2007
Jan 14th, 2009
0

Re: Capturing username and displaying on another page

Click to Expand / Collapse  Quote originally posted by it2051229 ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mirainc is offline Offline
9 posts
since Jul 2008
Jan 14th, 2009
0

Re: Capturing username and displaying on another page

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.
html Syntax (Toggle Plain Text)
  1. <form action="submit.php" method="GET"> <!--or "POST"-->
  2. <input type="text" name="username" />
  3. </form>

submit.php Set the session variable
php Syntax (Toggle Plain Text)
  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
php Syntax (Toggle Plain Text)
  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]
Reputation Points: 20
Solved Threads: 13
Junior Poster in Training
humbug is offline Offline
93 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Video to FLV
Next Thread in PHP Forum Timeline: problem uploading photo in webserver





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC