English

Write Programs for the following. Write a PHP code which calculates square of any number using form. - Information Technology

Advertisements
Advertisements

Question

Write Programs for the following.

Write a PHP code which calculates square of any number using form.

Answer in Brief
Advertisements

Solution

Coding:

<html>
<body>
<form method="post">
Enter a Number
<input type="text" name="sq"><br><br>
<input type="submit" name="submit" value="Sqaure">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$sq= $_POST['sq'];
$s=$sq*$sq;
echo "<br><br> The Square of number is: ".$s;
}
?>
shaalaa.com
PHP Form Connectivity with Database
  Is there an error in this question or solution?
Chapter 5: Server-Side Scripting (PHP) - Exercises [Page 78]

APPEARS IN

Balbharati Information Technology (Science) [English] Standard 12 Maharashtra State Board
Chapter 5 Server-Side Scripting (PHP)
Exercises | Q 7.1 | Page 78
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×