jcbones commented on a Page, My first PHP  -  Dec 19, 2008

Nah, PHP won't parse symbols like that, it will just print it back to the page.

Try this instead...

<?php
$form = "<form action=\"test.php\" method=\"post\"><input type=\"text\" value=\"\" name=\"one\"/><br/><input type=\"text\" value=\"\" name=\"two\"/><br/><input type=\"text\" value=\"\" name=\"three\"/><br/><input type=\"submit\" value=\"submit\" name=\"submit\"/></form>";

if($_POST["submit"])
{
  if($_POST["two"] == "+") {$value = $_POST["one"] + $_POST["three"]; echo $_POST["one"] ." + " . $_POST["three"] . " = " . $value;}
elseif($_POST["two"] == "-") {$value = $_POST["one"] - $_POST["three"]; echo $_POST["one"] . " - " . $_POST["three"] . " = " . $value;}
elseif($_POST["two"] == "*") {$value = $_POST["one"] * $_POST["three"]; echo $_POST["one"] . " * " . $_POST["three"] . " = " . $value;}
elseif($_POST["two"] == "/") {$value = $_POST["one"] / $_POST["three"]; echo $_POST["one"] . " / " . $_POST["three"] . " = " . $value;}
else echo "You have entered an unknown operator!";

}

else echo stripslashes($form);

?>
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.