Thursday, 28 January 2021

PHP-SEM3-3

extrafun.php

 

<?php

function add($n1,$n2, $ch)

{

if($ch==1)

{

$c = $n1 + $n2;

echo"addition is: $c";

}

else if($ch==2)

{

$c = $n1 - $n2;

echo"subtraction is: $c";

}

else if($ch==3)

{

$c = $n1 * $n2;

echo"multiplication is: $c";

}

else if($ch==4)

{

$c = $n1 / $n2;

echo"Division is: $c";

}

}

?>

 corephpslip3sem3.php

<?php

$n1 = $_POST['a'];

$n2 = $_POST['b'];

$ch = @$_POST['c'];

include 'extrafun.php';

add($n1,$n2, $ch=1);

?>

 Slip3.html

 <html>

<body>

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

<table border="1">

<tr>

<td>Enter first number :</td>

<td><input type=text name='a' value="" ></td>

</tr>

              

<tr>

<td>Enter second number:</td>

<td><input type=text name='b' value="" ></td>

</tr>            

 

<tr>

<td>                                                                                            

Operation::</td>

<td><input type=radio name='c' value='1'>Addition.</td>

<td><input type=radio name='c' value='2'>Subtraction.</td>

<td><input type=radio name='c' value='3'>Multiplication.</td>

<td><input type=radio name='c' value='4'>Division.</td>

</tr> 

                                   

<tr>

<td><input type=submit value='ok'> </td>

<td><input type=reset value='clear'></td>

</tr>

</table>

</form>

</body>

</html>