Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 642349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:09:41+00:00 2026-05-13T21:09:41+00:00

I have two pages, A and B. I want to echo a variable written

  • 0

I have two pages, A and B.

I want to echo a variable written in A inside of the page in B.

Here’s the first page:

<?php session_start(); ?>

<html>
    <head>
        <title>Registration Form - 1 of 2</title>
    </head>

<body>
    <h1>Registration - Part 1 of 2</h1>
    <p>Please fill in all the required information before submitting the information.</p>
    <form action="registerFormTwo.php" method="post">
        First Name:<input type="text" name="firstName" /><br /><?php $_SESSION['firstName'] = firstName; ?>
        Last Name:<input type="text" name="lastName" /><br /><?php $_SESSION['lastName'] = lastName; ?>
        Age:<input type="text" name="age" /><br /><?php $_SESSION['age'] = age; ?>
        Date of Birth:<input type="text" name="dateOfBirth" /><br /><?php $_SESSION['dateOfBirth'] = dateOfBirth; ?>

        <input type="submit" />
    </form>
</body>

And here’s the second one:

<?php session_start(); ?>

<html>
    <head>
        <title>Registration Form - 2 of 2</title>
    </head>

<body>
    <h1>Registration - Part 2 of 2</h1>
    <p>Please fill in all the required information before submitting the information.</p>        
    <?php //wrote this in just to test that session information is saving, but it isn't.
    echo $_SESSION['name']; ?>

    <form action="registerFinish.php" method="post">
        Nationality<input type="text" name="nationality" /><br /><?php $_SESSION['nationality'] = nationality; ?>
        Profession:<input type="text" name="profession" /><br /><?php $_SESSION['profession'] = profession; ?>

        <input type="submit" />
    </form>
</body>

On the second page, the name variable should be echoed, but nothing shows.

Thank you for the help.

EDIT:

Here’s the code on formOne and it’s still not working:

<?php session_start();
if ($_POST) {
  // Store our name in the session array
  $_SESSION["firstName"] = $_POST["firstName"];
}
?>

<html>
    <head>
        <title>Registration Form - 1 of 2</title>
    </head>

    <body>
        <h1>Registration - Part 1 of 2</h1>
        <p>Please fill in all the required information before submitting the information.</p>
        <form action="registerFormTwo.php" method="post">
            First Name:<input type="text" name="firstName" /><br />
            Last Name:<input type="text" name="lastName" /><br /><?php $_SESSION['lastName'] = lastName; ?>
            Age:<input type="text" name="age" /><br /><?php $_SESSION['age'] = age; ?>
            Date of Birth:<input type="text" name="dateOfBirth" /><br /><?php $_SESSION['dateOfBirth'] = dateOfBirth; ?>

            <input type="submit" />
        </form>
    </body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:09:41+00:00Added an answer on May 13, 2026 at 9:09 pm

    Form data doesn’t go directly into $_SESSION. You have to place it there. Since your form method is POST, you could pull your data out of $_POST on the server-side:

    session_start();
    if ($_POST) {
      // Store our name in the session array
      $_SESSION["name"] = $_POST["name"];
    }
    

    If you simply want to keep values in a form when the form submission failed, you don’t need to use sessions. You can reprint the value from $_POST directly into the markup again:

    <input type="text" name="name" value="<?php print $_POST["name"]; ?>" />
    

    Keep in mind that all of this takes place on the page that you’re posting to. If your first form is on page1.php, then you would ignore all of this. If you’re posting from page1.php to page2.php, you would place the aforementioned code on page2.php.

    Update

    I just noticed the following beside your form elements:

    <?php $_SESSION['lastName'] = lastName; ?>
    

    lastName doesn’t represent anything here. $_POST["lastName"] would represent the posted data. If you were trying to print the last-submitted value, I would do this:

    <?php print $_POST["lastName"]; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two html pages, when you click on something on the first html,
I currently have two html pages, a server hosted page, and a client hosted
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
I have two websites, let's say they're example.com and anotherexample.net . On anotherexample.net/page.html ,
I have a form within a php page. And I want to stop it's
I have two pages of jQuery, Page1 and Page2, and I'm able to get
Ok, i have simple scenario: have two pages: login and welcome pages. im using
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the
We have some web pages which have two frames, with one frame in the
I have two forms on a page (one is being grabbed by AJAX). I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.