Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

User's Input in PHP using Single File:-

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>



Post a Comment

POST Answer of Questions and ASK to Doubt

Previous Post Next Post