0% found this document useful (0 votes)
24 views3 pages

Calculator Assignment

The document details an assignment to create a basic calculator web application using HTML and PHP. It includes the HTML and PHP code to build a form that accepts two numeric values and buttons to perform addition, subtraction, multiplication and division, displaying the result.

Uploaded by

h24820909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Calculator Assignment

The document details an assignment to create a basic calculator web application using HTML and PHP. It includes the HTML and PHP code to build a form that accepts two numeric values and buttons to perform addition, subtraction, multiplication and division, displaying the result.

Uploaded by

h24820909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name : Basit Jawad

Semester : 6th BCS Open

Batch : 13

Subject :Web Engineering

Assignment :1

// Add.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculator</title>
</head>
<style>

</style>
<body>

<form action="Add.php" method="post">

<table border="1">
<tr>
<td><label >First value</label> <td><input type="text"
name="val1"></td> </td>
</tr>
<tr>
<td><label >Second value</label> <td><input type="text"
name="val2"></td> </td>
</tr>
<tr>
<td><button type="submit" name="addbt">ADD</button><td><button
type="submit" name="subbt">SUB</button></td>
</tr>
<tr>
<td><button type="submit" name="mulbt">MUL</button></td>
<td><button type="submit" name="divbt">DIV</button></td>
</tr>
</table>
</form>
</body>
</html>
//Add.html ends here

// Add.php starts here

<?php
if(isset($_POST['val1']) && isset($_POST['val2'])) {
$var1 =$_POST['val1'];
$var2 = $_POST['val2'];
if( isset($_POST['addbt'])){
$add=$var1+ $var2;
echo " <h2>Sum of two values is = $add </h2> ";

}
else if(isset($_POST['subbt'])){
$sub=$var1- $var2;
echo " <h2>Subtraction of two values is = $sub </h2> ";

}
else if(isset($_POST['mulbt'])){

$mul=$var1 * $var2;
echo " <h2>Multiplication of two values is = $mul</h2> ";

}
else if(isset($_POST['divbt'])){

if($var2==0){
echo "Division not possible";
}
else {
$div=$var1 / $var2;
echo " <h2>Division of two values is = $div</h2> ";
}
}
else{
echo "Invalid values ";
}
}

?>
//Add.php ends here

You might also like