How to run a external program in PHP?

Help me to edit and run this program that answer the fractional form using php html?

  • <html> <head><title>Act1</title></head> <body><form action="act1.php" method=Post> <p>Enter first numerator: <input type=text name=num1 size=20></p> <p>Enter first numerator: <input type=text name=num2 size=20></p> <p>Enter second denomenator: <input type=text name=num1 size=20></p> <p>Enter second denomenator: <input type=text name=num2 size=20></p> <p>Type of operation: <input type="radio" name="addition" value="x">ADDITION <input type="radio" name="subtraction" value="x">SUBTRACTION <input type="radio" name="multiplication" value="x">MULTIPLICATION <input type="radio" name="division" value="x">DIVISION <br> <p><input type=Submit value="Click Me" name=cmdclick></p> <?php function add($n1,$n2) { return $n1+$n2; } function subtract($n1,$n2) { return $n1-$n2; } function multiply($n1,$n2) { return $n1*$n2; } function divide($n1,$n2) { return $n1/$n2; } if ($operation==1) { $result=add($num1,$num2); echo "The result of adding the two numbers is: $result"; } if ($operation==2) { $result=subtract($num1,$num2); echo "The result of subtracting the two numbers is: $result"; } if ($operation==3) { $result=multiply($num1,$num2); echo "The result of multiplying the two numbers is: $result"; } if ($operation==4) { $result=divide($num1,$num2); echo "The result of dividing the two numbers is: $result"; } ?> </body> </html>

  • Answer:

    First of all, change this: <p>Enter first numerator: <input type=text name=num1 size=20></p> <p>Enter first numerator: <input type=text name=num2 size=20></p> <p>Enter second denomenator: <input type=text name=num1 size=20></p> <p>Enter second denomenator: <input type=text name=num2 size=20></p> to this: <p>Enter first numerator: <input type=text name=num1 size=20></p> <p>Enter first denomenator: <input type=text name=num2 size=20></p> <p>Enter second numerator: <input type=text name=num3 size=20></p> <p>Enter second denomenator: <input type=text name=num4 size=20></p> Then based on the operation selected, implement the proper logic there (its basic math) and then your program will work. Good luck!!

mark79_2... at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.