How to create HTML form that accept user name and display it using PHP ? Last Updated : 24 Jun, 2021 Comments Improve Suggest changes Like Article Like Report Through HTML forms various data can be collected from the user and can be sent directly to the server through PHP scripting. There are basically two methods for sending data to the server one is "GET" and the other one is "POST". In GET method, the data goes through the browser's URL and can be seen by anyone using the browser, and it is not very safe when sending crucial or highly confidential data. But with the POST method, the data is directly sent to the server, and it can't be seen by anyone, and it is considered the most secure way to send the information to the server. Generally, the GET method is used by the search engines because it reads the data but for the data to be maintained or changed, the POST method is used for it. Approach: We will see one example of the HTML form collecting the first and last name of the person and sending the data to the DOM which eventually displays the data on the screen using PHP script.  Example: HTML <!DOCTYPE html> <html> <body> <!-- Heading --> <h3> HTML input form </h3> <!-- HTML form --> <form method="POST"> <h4>Please enter your First Name : </h4> <input type="text" name="f_name"><br> <h4>Please enter your Last Name : </h4> <input type="text" name="l_name"><br><br> <input type="submit" value="Display" name="submit"> </form> </body> </html> <?php // When the submit button is clicked if (isset($_POST['submit'])) { // Creating variables and // storing values in it $f_name = $_POST['f_name']; $l_name = $_POST['l_name']; echo "<h1><i> Good Morning, $f_name $l_name </i></h1>"; } ?> Output: Comment More infoAdvertise with us Next Article How to create HTML form that accept user name and display it using PHP ? jimishravat2802 Follow Improve Article Tags : PHP PHP-function HTML-Questions PHP-Questions Similar Reads How to extract the user name from the email ID using PHP ? Given a string email address, extract the username. Input: âpriyank@geeks.comâ Output: priyank Input: âprincepriyank@gfg.comâ Output: princepriyank Approach 1: Using PHP strstr() to extract the username from the email address. In this, â@â symbol is the separator for the domain name and user name of 2 min read How to define a form for user input using HTML5 ? In this article, we will learn how to create a form in a webpage by using the <form> tag. This tag is used to create form for user input. Also there are many elements which are used within form tag. Syntax: <form> Form Content... </form> Example: The following code snippet demonstr 1 min read How to create a hidden input field in form using HTML ? In this article, we will learn how to add a hidden input field into our form using HTML. A hidden control stores the data that is not visible to the user. It is used to send some information to the server which is not edited by the user. Normally, this hidden field usually contains the value which i 2 min read How to Add a Telephone Number into a form using HTML? In this article, we will learn how to add a telephone number field to an HTML form. Telephone numbers have numerous advantages and are an important component of contact forms, allowing for direct communication with the user. Users can receive messages or notifications regarding the services provided 2 min read How to Display an Error for Invalid Input with PHP/HTML? PHP can be easily embedded in HTML files, and HTML code can also be written in a PHP file. The key difference between PHP and a client-side language like HTML is that PHP code is executed on the server, while HTML code is directly rendered in the browser. To display errors for invalid input using HT 2 min read How to Insert Email Address into Form using HTML5 ? In this article, we will learn how to add and get an email address of a user as data of the form by adding an email input field. As we know that an email_id is a vital component of user data. Email address is used for the verification of the user. It is also used to make contact with the submitters 2 min read How to create a form with custom buttons in HTML ? HTML form contains other form elements like text box, check box, radio button, submit button, and many more. For creating an HTML form, <form>________</form>tag is used as it is paired tag so starting and closing tags both are required. Other form elements are placed within these tags. I 3 min read How to take user input for two dimensional (2D) array in PHP ? There are two methods to take user input in PHP in two dimensional (2D) array. Approach 1: Use HTML forms through PHP GET & POST method to take user input in two dimensional (2D) array.First, input data into HTML forms.Then use the GET or POST method of PHP to get or post those input data into 3 min read Create a Contact Form using HTML CSS & JavaScript A contact form is a web form used to collect user information and messages, facilitating communication between visitors and site owners. It is essential for feedback, inquiries, and support. Create a contact form using HTML for structure, CSS for styling, and JavaScript for validation and submission 3 min read How to get form data using POST method in PHP ? PHP provides a way to read raw POST data of an HTML Form using php:// which is used for accessing PHPâs input and output streams. In this article, we will use the mentioned way in three different ways. We will use php://input, which is a read-only PHP stream. We will create a basic HTML form page wh 2 min read Like