Code 1 for checking input are numeric
if ($_SERVER["REQUEST_METHOD"] == "POST"):
if(!preg_match("/^[0-9]+$/", $_POST['number1'])):
$numerr1 = "Please Enter number only";
else:
$num1 = $_POST['number1'];
endif;
if(!preg_match("/^[0-9]+$/", $_POST['number2'])):
$numerr2 = "Please Enter number only";
else:
$num2 = $_POST['number2'];
$sum = sum($num1, $num2);
$subtract = subtract($num1, $num2);
$divide = divide($num1, $num2);
$multiply = multiply($num1, $num2);
endif;
endif;
code 2 to print results
if (isset($_POST['sum'])):
echo "Sum of $num1 and $num2 is: $sum";
endif;
if (isset($_POST['subtract'])):
echo "Subtraction of $num1 and $num2 is: $subtract";
endif;
if (isset($_POST['divide'])):
echo "Division of $num1 and $num2 is: $divide";
endif;
if (isset($_POST['multiply'])):
echo "Multiplication of $num1 and $num2 is: $multiply";
endif;
the thing is Every time i enter 2nd number as zero it takes me to a blank screen .... how can i fix this?