Here is a sample program that I wrote that will accept two numbers from the user and then it will add and subtract the two value given by the user using PHP as my programming language.
I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.
Sample Program Output
Program Listing
index.php
<html>
<head>
<title>
Addition and Subtract of Two Numbers in PHP
</title>
<style>
body {
background-color: lightgreen;
font-family: arial;
font-weight: bold;
font-size: 15px;
}
#textInput2 {
width:170px;
height:100px;
margin-left:5px;
}
</style>
</head>
<?php
error_reporting(0);
$x=$_POST['num1'];
$y=$_POST['num2'];
if(isset($_POST['clear']))
{
$x="";
$y="";
}
?>
<body>
<br><br><br>
<h1> Addition and Subtract of Two Numbers in PHP </h1>
<br><br>
<form method="post">
<label id="textInput2"> Enter first number </label>
<input type="text" name="num1" value="<?php echo $x; ?>" autofocus/>
<br><br>
<label id="textInput2">
Enter second number </label>
<input type="text" name="num2" value="<?php echo $y; ?>"/>
<br><br>
<input type="submit" name="add" value="ADD"/>
<input type="submit" name="subtract" value="SUBTRACT"/>
<input type="submit" name="clear" value="CLEAR"/>
<br><br><br>
</form>
<?php
if(isset($_POST['add']))
{
$sum=$x+$y;
echo "Result:
 
<input type='text' value='$sum'/ readonly>";
}
if(isset($_POST['subtract']))
{
$subtract=$x-$y;
echo "Result:
 
<input type='text' value='$subtract'/ readonly>";
}
?>
</body>
</html>