I have my code for my PHP:
<?php
$num1= $_REQUEST["number1"];
$num2= $_REQUEST["number2"];
$arithmetic = $_POST['arithmetic'];
switch ($arithmetic) {
case "addition":
$answer = $num1+$num2;
echo "<p>$num1 added with $num2 is " . number_format($answer,2) . "</p>";
break;
case "subtraction":
$answer = $num1-$num2;
echo "<p>$num2 subtracted from $num1 is " . number_format($answer,2) . "</p>";
break;
case "multiplication":
$answer = $num1*$num2;
echo "<p>$num1 multiplied by $num2 is " . number_format($answer,2) . "</p>";
break;
case "division":
$answer = $num1/$num2;
echo "<p>$num1 divided by $num2 is " . number_format($answer,2) . "</p>";
break;
case "modulus":
$answer = $num1%$num2;
echo "<p>The remainder of $num1 divided by $num2 is " . number_format($answer,2) . "</p>";
break;
}
?>
<br>
<form action="calcD.html" target="iframeMain">
<input type="submit" value="go back">
</form>
<?php
echo "<HR>";
highlight_file("calcD.php");
?>
and my code for my HTML:
<html>
<head>
<link href="reset.css" rel="stylesheet" type="text/css">
<link href="css3.css" rel="stylesheet" type="text/css">
<link href='http://ift.tt/1PObzoK' rel='stylesheet' type='text/css'>
</head>
<body>
<h2>Dropdown Calculator</h2>
<form action="calcD.php" method="POST" target="iframeMain" autocomplete="off">
<p>Number 1:<input type="text" name="number1"></p>
<p>Number 2:<input type="text" name="number2"></p>
<h3>Type of Arithmetic</h3>
<select name="arithmetic">
<option name="addition">Addition</option>
<option name="subtraction">Subtraction</option>
<option name="multiplication">Multiplication</option>
<option name="division">Division</option>
<option name="modulus">Modulus</option>
</select>
<input type="submit" name="compute" value="Compute">
</form>
<a href="assignment3.html" target="iframeMain">Back to Menu</a>
</body>
</html>
But when I try to use my programs, the answer doesn't display. I have check on multiple sites and there are no errors with my HTML nor my PHP but my answer is not displaying. I have even tried using If and Elseif statements for each program. Is there a link I am missing for them?
Aucun commentaire:
Enregistrer un commentaire