Hi, i made a simple php code, im not getting the incorrect answer, <? $num = "12"; $num2 = "3"; $cal = $num - $num2; echo $cal ; ?> <title><?php echo $cal?></title> <form action="page.php" method="POST"> what is <?php echo $num . " - " .$num2?> ? <input type="text" name="cap"> <input type="submit" value="Submit"> </form> PHP: <? $num = "12"; $num2 = "3"; $cal = $num - $num2; $cap = $_POST['cap']; if ($cal !== $cap){ echo "yes 12 - 3 is ". $cap; }else{ "No, the answare is incorect"; } ?> PHP:
If you are going to use strict variable comparisons (===. !===) the best way to test why the variables do not match is by using var_dump($var). Which will show you the variable type. You either have to typecast the values or just use normal comparison: <?php $num = 12; $num2 = 3; $cal = $num - $num2; $cap = (int) $_POST['cap']; if ($cal !== $cap) { echo "yes 12 - 3 is ". $cap; } else { "No, the answare is incorrect"; } PHP: Or: $num = "12"; $num2 = "3"; $cal = $num - $num2; $cap = $_POST['cap']; if ($cal != $cap) { echo "yes 12 - 3 is ". $cap; } else { "No, the answare is incorrect"; } PHP:
im not good whit php but i meant, if you enter the wrong number its still saying that yes 12 - 3 is any number . so in first/index page it says what is 12 - 3 ? if you enter the wrong/ any number its saying that yes 12 - 3 is displays any number you have entered.