- PHP Basics
- PHP Home
- PHP Environment Setup
- PHP Getting Started
- PHP Basic Syntax
- PHP echo
- PHP print
- PHP echo Vs print
- PHP Comments
- PHP Data Types
- PHP Variables
- PHP Variable Scope
- PHP gettype()
- PHP Constants
- PHP Operators
- PHP Program Control
- PHP Decision Making
- PHP if-elseif-else
- PHP switch
- PHP Loops
- PHP for Loop
- PHP while Loop
- PHP do-while Loop
- PHP foreach Loop
- PHP break & continue
- PHP Popular Topics
- PHP Arrays
- PHP print_r()
- PHP Strings
- PHP Functions
- PHP References
- PHP Object Oriented
- PHP Object Oriented
- PHP Classes & Objects
- PHP Member Variable
- PHP Member Function
- PHP Encapsulation
- PHP Data Abstraction
- PHP Inheritance
- PHP Constructor Destructor
- PHP Polymorphism
- PHP Web Developments
- PHP Web Developments
- PHP GET & POST
- PHP Read Requested Data
- PHP File Handling (I/O)
- PHP File Handling (I/O)
- PHP fopen() | Open File
- PHP Create a File
- PHP fwrite() | Write to File
- PHP fread() | Read File
- PHP feof()
- PHP fgetc()
- PHP fgets()
- PHP fclose() | Close File
- PHP unlink() | Delete File
- PHP Append to File
- PHP copy() | Copy File
- PHP file_get_contents()
- PHP file_put_contents()
- PHP file_exists()
- PHP filesize()
- PHP rename() | Rename File
- PHP fseek()
- PHP ftell()
- PHP rewind()
- PHP disk_free_space()
- PHP disk_total_space()
- PHP mkdir() | Create Directory
- PHP rmdir() | Remove Directory
- PHP glob() | Get Files/Directories
- PHP basename() | Get filename
- PHP dirname() | Get Path
- PHP filemtime()
- PHP file()
- PHP Advanced
- PHP Cookies
- PHP Sessions
- PHP Send Emails
- PHP Serialization
- PHP Namespaces
- PHP File Upload
- PHP Date and Time
- PHP Image Processing
- PHP Regular Expression
- PHP Predefined Variables
- PHP Error Handling
- PHP Debugging
- PHP and MySQLi Tutorial
- PHP and MySQLi Home
- PHP MySQLi Setup
- PHP MySQLi Create DB
- PHP MySQLi Create Table
- PHP MySQLi Connect to DB
- PHP MySQLi Insert Record
- PHP MySQLi Fetch Record
- PHP MySQLi Update Record
- PHP MySQLi Delete Record
- PHP MySQLi SignUp Page
- PHP MySQLi LogIn Page
- PHP MySQLi Store User Data
- PHP MySQLi Close Connection
- PHP connect_errno
- PHP connect_error
- PHP query()
- PHP fetch_row()
- PHP fetch_assoc()
- PHP fetch_array()
- PHP free_result()
- PHP error
- PHP prepare()
- PHP bind_param()
- PHP execute()
- PHP fetch()
- PHP store_result()
- PHP num_rows
- PHP bind_result()
- PHP get_result()
- PHP mysqli_result Class
- PHP Error Constants
- PHP mysqli_driver()
- PHP Misc
- PHP error_reporting()
- PHP Escape Special Characters
- PHP htmlspecialchars()
- PHP new
- PHP header()
- PHP getallheaders()
- PHP empty()
- PHP isset()
- PHP unset()
- PHP exit()
- PHP exit Vs break
- PHP include()
- PHP require()
- PHP include() Vs require()
- PHP AJAX & XML
- PHP AJAX
- PHP XML
- PHP File Handling Functions
- PHP abs()
- PHP Test
- PHP Online Test
- Give Online Test
- All Test List
PHP Read Requested Data
You can read the requested data using PHP like, when user enters their information into the form and wants to review the entered details, then you have to first read that data and prints back to the browser.
How to Read Requested Data using PHP
Here is an example shows how any requested data can be read using PHP.
<?php if($_SERVER['REQUEST_METHOD'] == "POST") { // reading the requested data // and storing the value to separate // variables if(isset($_POST['data1'])) { $data1 = $_POST['data1']; } if(isset($_POST['data1'])) { $data2 = $_POST['data2']; } if(isset($_POST['data3'])) { $data3 = $_POST['data3']; } if(isset($_POST['data4'])) { $data4 = $_POST['data4']; } } ?> <html> <head> <title>PHP Reading Requested Data Example</title> </head> <body> <?php if($_SERVER['REQUEST_METHOD'] == "POST") { echo "Reading first data...<br/>"; if(!empty($data1)) { echo "The first data is: ".$data1; } else { echo "Sorry, first data is empty."; } echo "<hr/>"; echo "Reading second data...<br/>"; if(!empty($data2)) { echo "The second data is: ".$data2; } else { echo "Sorry, second data is empty."; } echo "<hr/>"; echo "Reading third data...<br/>"; if(!empty($data3)) { echo "The third data is: ".$data3; } else { echo "Sorry, third data is empty."; } echo "<hr/>"; echo "Reading fourth data...<br/>"; if(!empty($data4)) { echo "The fourth data is: ".$data4; } else { echo "Sorry, fourth data is empty."; } exit(); } ?> <form method="POST"> Enter Data 1: <input type="text" name="data1"><br/> Enter Data 2: <input type="text" name="data2"><br/> Enter Data 3: <input type="text" name="data3"><br/> Enter Data 4: <input type="text" name="data4"><br/> <input type="submit" Value="Submit"> </form> </body> </html>
Here is the sample output (initial output) produced by the above reading requested data example code in PHP.

Now enter the information into all the four input boxes like this:

Now click on Submit button and watch the output, the output will looks like:

Again run the same code and this time fill only two box and left the rest two box as blank like this:

Now click on Submit button, the output this time will looks like:

« Previous Tutorial Next Tutorial »