×

Please Login or Register to continue.

4
(1.5K Views)

I want to create and HTML form with PHP functionality. I want to find out the area of the rectangle using HTML form and PHP. The result should be displayed in another text box. I explain - I want to create and HTML form text boxes to insert the values and result in the third input box (text box) using PHP.
(4.3K Points)
in PHP

Share

2 Answers
(9.4K Points)
(edited)
1

Yes, It is possible to insert the value in the input box and result in another text box. You can use the HTML form and a PHP script to find out the area of the rectangle on the button click. First of all, you need to know the mathematical formula for the area of the rectangle.  The mathematic formula for the area of the rectangle is A = wl. 

A = A denotes the area of the rectangle.

w= w denotes the width of the rectangle. 

l = l is the length of the rectangle. 

We can write this formula in PHP. like =  a=w*l ; 

You can see the w and l will be entered by the user. We create three text boxes in HTML. The two text boxes are for l and w and one text box for the result. 

When a user enters the l and w of the rectangle, the result is displayed in the third text box.

Let's create an HTML form.

<html>
<body>
<form action="" method="post">
Width :
<input type="text" name="w"><br>
Length :
<input type="text" name="l"><br>
<input type="submit" name="submit" value="area"><br>
</form>
</body>
</html>

 We created an HTML form with two input boxes and one button. Now create the PHP script to get the area of the rectangle in the third text box. 

 <?php
$a="";
if(isset($_POST['submit']))

{
$w=$_POST['w'];

$l=$_POST['l'];

$a=$w*$l;
}

?>
Result:<input type="text" value="<?php echo $a; ?>">



Now add this PHP code in a single file and execute. 

<html>
<body>
<form action="" method="post">
Width :
<input type="text" name="w"><br>
Length :
<input type="text" name="l"><br>
<input type="submit" name="submit" value="area"><br>
</form>
</body>
</html>
<?php
$a="";
if(isset($_POST['submit']))
{
$w=$_POST['w'];
$l=$_POST['l'];
$a=$w*$l;
}
?>
Result:<input type="text" value="<?php echo $a;?>">

 

Enter the width and length of the rectangle in text boxes, you will get the result into the third text box. 

 

 


Comment

(7.3K Points)
(edited)
0

You can find out the area of the rectangle after creating an HTML form and PHP script. That's really good to find out the area of the rectangle using the PHP script. Let's think about it. 

Create an HTML form with three input boxes- 

Input box 1- 

input box - 2 

input box 3 . 

Text box 1 and text box 2 are for the insert value and the third text box will be used to display the result. 

<html> 

<head> 

</head> 

<body> 

<input type="text" name="w"> 

<input type="text" name="l"> 

<input type="submit" name="submit"> 

</body> 

<html> 

You should understand the PHP script. The area of the rectangle is A=wl. 

I have a reference for you.

PHP: Add two input box values and sum in the third box 


Comment

Related Questions :-

Featured Items:-


Certificate system in PHP website | PHP scripts

$22



Home Credito loan finance management multipurpose system in PHP

$65



Result management system with Marksheet in PHP website | PHP Scripts

$39




Your Answer

You can post your answer after login..