User's Input in PHP using Single File

0

We can write PHP Script under HTML page but extension should be .php.We can not write PHP Script under .html file because .html file contain only static data hence, if we want to write PHP Code script then the page extension should be .php.
We can manage input operation in the same file.
Complete Program of PHP:-
Create .php file and write the below code under this.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="" method="post">
<input type="text" name="txtnum1" placeholder="Enter First Number" />
<br>
<br>
<input type="text" name="txtnum2" placeholder="Enter Second Number" />
<br>
<br>
<input type="submit" name="btnsubmit" value="Addition" />
</form>
<?php
if(isset($_REQUEST['btnsubmit']))
{
$num1 = $_REQUEST['txtnum1'];
$num2 = $_REQUEST['txtnum2'];
$num3 = $num1+$num2;
echo $num3;
}
?>
</body>
</html>
Tags

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)