PHP使用Post方法将变量从页面传输到第三页[重复]

This question already has an answer here:

I have a Login Page with the following Code;

                <p> Login  Name</p>
                <p>
           <input type="text" 
                  name="username" id="username">


    <input type="submit" name="submit" value="submit">


        </p>
            <p>
              <label for="password">Password<br />
                <br />
              </label>
              <input name="password" 
              type="password" id="password"></input>

            </p>

        <p>

          <input type="submit" value="Login"/>
          <input type="reset" value="Reset"/>
          </p>
        <p><br />

and after capturing

i have also this code using the inputs

   require('config\db.php');
  session_start();
  // If form submitted, insert values into the database.
  if (isset($_POST['username'])){
  //$username1 = $_POST['username1'];;
    $username = $_POST['username'];
    $password = $_POST['password'];
    $username = stripslashes($username);
    $username = mysql_real_escape_string($username);
    $password = stripslashes($password);
    $password = mysql_real_escape_string($password);

I open a Page which has some options on logging in . I select one option on that page using radio buttons. It opens a third page.

I want to display the User Name captured on the first page.

How can i do this? Any help will be highly appreciated.

</div>

You have to store it somewhere.

A hidden input in the form in the second page is pretty reliable.

A session is a common choice, although subject to race conditions.

Store that user name in session
Then you can use it anywhere

To use session to should write session_start(); which you have done.

Now just store your username in session.

$_SESSION['username']=$username;

echo you can print it by just

echo $_SESSION['username'];

for more information go here