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>
<form action="" method="post">
<input type="text" name="txtnum1" placeholder="Enter First Number" />
<input type="text" name="txtnum2" placeholder="Enter Second Number" />
<input type="submit" name="btnsubmit" value="Addition" />
$num1 = $_REQUEST['txtnum1'];
$num2 = $_REQUEST['txtnum2'];
$num3 = $num1+$num2;
echo $num3;

Post a Comment


POST Answer of Questions and ASK to Doubt

Post a Comment (0)