Mike Cherim | +------------------------------------------------------------------+ */ ?> Reset'; // Do the basic math operations (probably a way to combine into one string but I couldn't figure it out if ($operation == "+") { $theanswer = $input_one + $input_two; } if ($operation == "-") { $theanswer = $input_one - $input_two; $operation = "–"; // To display a better symbol } if ($operation == "*") { $theanswer = $input_one * $input_two; $operation = "×"; // To display a better symbol } if ($operation == "/") { $theanswer = $input_one / $input_two; $operation = "÷"; // To display a better symbol } // In case a bot submits large values - people are limited by the input maxlengths if (strlen($input_one) > 10 || strlen($input_two) > 10 ) { $theoutput = '
Error: Input limit exceeded.'.$the_reset.'
'; } else // In case the inputs are left empty... can't add air, right? if( empty($input_one) || empty($input_two) ) { $theoutput = 'Error: You must enter values.'.$the_reset.'
'; } else // In case someone tries letter math or other stuff // There is a better way to do this. If you know how, please email me at "mikecherim" at my green-beast.com domain if( !preg_match("([0-9])", $input_one) || !preg_match("([0-9])", $input_two) || preg_match("([a-z])i", $input_one ) || preg_match("([a-z])i", $input_two ) ) { $theoutput = 'Error: Enter numbers only.'.$the_reset.'
'; } // All's well, let's create an output string else { $theoutput = "Output: "."$input_one"." $operation "."$input_two"." = "."$theanswer $the_reset"."
"; } } ?>