All the values are stored in the $_POST collection

<?php print_r($_POST); ?>

or if you want something fancier that is easier to read use a foreach loop to loop through the $_POST collection and print the values.

<table>
<?php 


    foreach ($_POST as $key => $value) {
        echo "<tr>";
        echo "<td>";
        echo $key;
        echo "</td>";
        echo "<td>";
        echo $value;
        echo "</td>";
        echo "</tr>";
    }


?>
</table>
Answer from Jared on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 50264676 › echoed-form-data-and-manupulation-with-get-and-post-in-php
html - Echoed form data and manupulation with GET and POST in PHP - Stack Overflow
Copy <?php echo "<html><body>"; if(isset($_POST['submit'])) { $name = $_POST['firstname']; echo "User Has submitted the form and entered this name : <b> $name </b>"; } echo"<form action=$_SERVER['PHP_SELF']> First name:<br> <input type='text' name='firstname' value='John'><br> Last name:<br> <input type='text' name='lastname' value='Rambo'><br><br> <input type='submit' value='Submit'> </form></body></html>"; ?>
Discussions

PHP: Echoing an input submitted from a form
I have a form which contains one text field. Now, I'm trying to echo out the contents of that input after the form was submitted. Here's my code for the same: function More on stackoverflow.com
🌐 stackoverflow.com
August 23, 2015
Why is my HTML/PHP form echoing the PHP file and using get when post is specified? - Stack Overflow
I've been working on a website for my father for a while now and i have been getting frustrated with the contact form and order form. I'm only starting to learn HTML and i don't know a whole lot ab... More on stackoverflow.com
🌐 stackoverflow.com
php - echo form data? - Stack Overflow
I'm trying to produce a registration form, basically i have 4 pages, page one asks for first name, last name and email, page two asks for date of birth and password, page 3 will ask some statistics/ More on stackoverflow.com
🌐 stackoverflow.com
May 24, 2017
forms - PHP: Possible to automatically get all POSTed data? - Stack Overflow
Simple question: Is it possible to get all the data POSTed to a page, even if you don't know all the fields? For example, I want to write a simple script that collects any POSTed data and emails i... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Tutorial Republic
tutorialrepublic.com › php-tutorial › php-get-and-post.php
Difference Between HTTP GET and POST Methods - Tutorial Republic
Like $_GET, PHP provide another superglobal variable $_POST to access all the information sent via post method or submitted through an HTML form using the method="post". ... <!DOCTYPE html> <html lang="en"> <head> <title>Example of PHP POST ...
🌐
Tutorial Republic
tutorialrepublic.com › php-tutorial › php-form-handling.php
How to Access Submitted Form Data in PHP - Tutorial Republic
In this tutorial you'll learn how to collect user inputs submitted through a form using the PHP superglobal variables $_GET, $_POST and $_REQUEST.
🌐
OSTraining
ostraining.com › blog › coding › retrieve-html-form-data-with-php
How To Retrieve HTML Form Data With PHP - OSTraining
December 8, 2022 - Then the form field, first name ... assigned to a variable name that was used to display the results. The form POST method sends information via HTTP header....
🌐
W3Schools
w3schools.com › php › php_forms.asp
PHP Form Handling
When a user fills out the form ... is sent with the HTTP POST method. To display the submitted data you could simply echo all the variables....
🌐
DevSense
blog.devsense.com › 2019 › php-forms-get-and-post
PHP Basics: Forms, GET, and POST - DEVSENSE Blog
July 15, 2019 - This makes it pretty simple to collect our values from our submitted forms. If we want to handle the input firstName sent via POST, we just capture it like so:
🌐
InformIT
informit.com › articles › article.aspx
Accessing Form Variables | PHP Crash Course | InformIT
One of the $_GET or $_POST arrays holds the details of all the form variables. Which array is used depends on whether the method used to submit the form was GET or POST, respectively. In addition, a combination of all data submitted via GET or POST is also available through $_REQUEST.
Find elsewhere
Top answer
1 of 2
1

try this using session ,

    <? ob_start(); 
         session_start();?>
<?php
// GET ACCOUNT INFORMATION FROM FORM AND ASSIGN VARIABLES
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
?>
<?php
/*
// ECHO ACCOUNT INFORMATION
echo "<strong> Account Information: </strong>";
echo "<br />";
echo First Name: ";
echo "<br />";
echo $first_name;
echo "<br />";
echo "<br />";
echo "Last Name: ";
echo "<br />";
echo $last_name;
echo "<br />";
echo "<br />";
echo "Email: ";
echo "<br />";
echo $email;
echo "<br />";
echo "<br />";
*/
?>

<?php
////// SEND TO DATABASE


/////////////////////////////////////////////////////////

// Database Constants
define("DB_SERVER", "#######");
define("DB_USER", "######");
define("DB_PASS", "");
define("DB_NAME", "######");

// 1. Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if (!$connection) {
    die("Database connection failed: " . mysql_error());
}

// 2. Select a database to use
$db_select = mysql_select_db(DB_NAME,$connection);
if (!$db_select) {
    die("Database selection failed: " . mysql_error());
}
//////////////////////////////////////////////////////////////
$query="INSERT INTO registrations (Id,
first_name,
last_name,
email

 )
VALUES('NULL',
'".$first_name."',
'".$last_name."',
'".$email."'
)";
mysql_query($query) or die ('Error updating database');
?>
<?php
function confirm_query($result_set) {
                if (!$result_set) {
                    die("Database query failed: " . mysql_error());
                }
        }
function get_user_id() {
    global $connection;
    global $email;
    $query = "SELECT *
                FROM registrations
                WHERE email = \"$email\"
                ";
        $user_id_set = mysql_query($query, $connection);
        confirm_query($user_id_set);
        return $user_id_set;
        }
?>
<?php
$user_id_set = get_user_id();
while ($user_id = mysql_fetch_array($user_id_set)) {
    $cookie1 = "{$user_id["id"]}";
    setcookie("registrations", $cookie1, time()+3600);  /* expire in 1 hour */

}
?>


    <? ob_flush(); ?>

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>Register</title>

            <!-- The stylesheet -->
            <link rel="stylesheet" href="assets/css/styles.css" />

            <!--[if lt IE 9]>
              <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
            <![endif]-->
        </head>

        <body>
            <div id="main">

            <h2>Step 2: Security Details</h2>
            <br/>

                <form class="" method="post" action="register_p3.php">

                    <div class="row date_of_birth">
                        <input type="text" id="date_of_birth" name="date_of_birth" placeholder="D.O.B 10/02/1990" />
                    </div>

                    <div class="row password">
                        <input type="password" id="password" name="password" placeholder="Password" />
                    </div>

                    <div class="row password2">
                        <input type="password" id="password2" name="password2" placeholder="Password (Confirm)"  />
                    </div>

                    <input type="submit" value="Next >"  />

                </form>
            </div>
            <!-- JavaScript includes - jQuery, the complexify plugin and our own script.js -->
            <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
            <script src="assets/js/jquery.complexify.js"></script>
            <script src="assets/js/script.js"></script>     
        </body>
    </html>
2 of 2
0

If you want information to be available on more than one page you should store it in a session. Just do something like this when you store the $_POST values into variables, and be sure to put a session_start(); call at the top of your page.

<?php
session_start();
// other php code here

$_SESSION['first_name'] = $first_name;
$_SESSION['last_name'] = $last_name;
$_SESSION['email'] = $email;
?>

Then you could access them on any page by calling $_SESSION['first_name'] or whatever variable you want to access. Just be sure to include session_start(); at the top of every page that requires using these variables.

🌐
Tutorialspoint
tutorialspoint.com › php › php_get_post.htm
PHP - GET & POST
<?php if( $_GET["name"] || $_GET["age"] ... = "text" name = "age" /> <input type = "submit" /> </form> ... The POST method transfers information via HTTP headers....
🌐
GeeksforGeeks
geeksforgeeks.org › php › get-and-post-in-php
$_GET and $_POST in PHP - GeeksforGeeks
July 23, 2025 - More secure than $_GET for handling sensitive information like passwords. Accessed using associative array notation, e.g., $_POST['field_name']. <?php echo $_POST['username']; // Outputs the value of the 'username' parameter submitted via POST ?>
🌐
Guru99
guru99.com › home › php › php registration form using get, post methods with example
PHP Registration Form using GET, POST Methods with Example
July 25, 2026 - This is the built-in PHP superglobal array variable that is used to get values submitted via the HTTP GET method.
🌐
EITCA
eitca.org › home › how can we access the form data sent through the get and post methods in php?
How can we access the form data sent through the GET and POST methods in PHP? - EITCA Academy
August 8, 2023 - To access form data sent through the GET and POST methods in PHP, we can use the $_GET and $_POST superglobal arrays respectively. These arrays provide a convenient way to retrieve and process the form data submitted by the user.
🌐
PHP
php.net › manual › en › tutorial.forms.php
PHP: Dealing with Forms - Manual
If we used the method GET then our form information would live in the $_GET superglobal instead. You may also use the $_REQUEST superglobal, if you do not care about the source of your request data. It contains the merged information of GET, POST and COOKIE data. Learn How To Improve This Page • Submit a Pull Request • Report a Bug
🌐
FormGet
formget.com › home › php › php get and post method – tutorial
PHP GET and POST Method – Tutorial | FormGet
August 1, 2014 - To send submitted data through form, one can use GET & POST method to do that. A form data can be submitted using these two methods.
🌐
Medium
medium.com › @javasper › how-to-handle-a-forms-data-using-php-f5345c7303d2
How To Handle A Form’s Data Using PHP | by Eric Tam | Medium
October 25, 2021 - You will learn how to collect data that the user sends via inputs using either the GET or POST method. So let’s start off with an overview of what a form is. ... So if you want the user to be able to send data to you, you need to use a form. ... <html> <head><title></title></head> <form action=‘page1.php’ method=‘POST’> <input type=‘text’ name=‘text1’> <input type=‘submit’ value=‘Submit’> </form> </body> </html>