How to Display Result in Textbox in PHP -

PHP Display result in Textbox

PHP 6 Months 100% Job Assistance Program. for more info... call on 8588829328

How to display Result in textbox in PHP

How to get input from HTML, do calculation and display output in text box.

Write a program to add two numbers and print the result in third text box.

To display the output in third text box there are many ways.
First way : Take input from HTML make calculation and display the output in text box, for this use <input type=”text” value=”output”/> inside PHP script.

Enter first number
Enter second number

In the given example

First we design two textbox using HTML script with attribute name with ( value=”Fnum” for first textbox) and (value= “Snum” for second textbox). A submit button with (name=Add).

when we run the program the logic that is defined inside PHP script, $_POST[ ] is used to collect the values from a form. it store the value in variables ($x,$y).

But we want to show the sum inside the textbox. for this we define textbox inside the “echo” statement with (value=”$sum”).


WAP Sum of two number and display the Result in third text box

Enter first number
Enter second number

In previous example the textbox is defined inside the PHP script. Instead this We define third textbox outside the PHP script.

Value attribute of <Input> tag is used to show the output inside the textbox here we define a PHP script inside the value Property of the textbox.

Fill Registration form, show Output in text box

Create a Registration form fill all the information and display the result in text box on next page

Save the program as registration form.html


Registration Form
Enter Your Name
Enter Your Email
Enter Your Password
Enter Your Mobile Number
Enter Your Address


Save the program as output.php


Your Output will display like
Your Name is
Your Email is
Your Password is
Your Mobile Number is
Your Address is


We create form using HTML script with (method=”post”) and action=”output.php”.
We define Five fields inside the HTML form.

First for name,Second for Email_id, Third for Password,Fourth for Mobile No,and Fifth for address.
A button is used to display data on next page after click on this button.

inside the (output.php) page we create same form format. But value attribute of every <input> type tag is used to declare the PHP script inside the value with $_POST[ ] . $_POST[ ] is define with name of a field like. $_POST[‘name’], $_POST[’email’].

As we run this program the dada that is Entered in First page will dispaly as it is data on Second(output.php) page.

Latest Trending Technologies