Home » Php » PHP Pythagoras check if it's the right answer

PHP Pythagoras check if it's the right answer

Posted by: admin October 29, 2018 Leave a comment

Questions:

Hello i made this code below but i want it to be able to check if i guessed the answer good. If i insert 3 and 4 the answer is 5 but how do i let the code check if the answer “5” is right with the 2(“3 and 4”) input fields. So if all three input fields are correct. echo good and if not echo false. I am bad at explaining but i hope it’s clear.

<form method="POST">
<label>Rechthoek verticaal</label>
<input name="vert"></input>
<label>Rechthoek horizontaal</label>
<input name="hor"></input>
<label>Schijne zijde</label>
<input name="schuin"></input>
<input type="submit" name="submit"></input>
</form>

<?php

if(isset($_POST['submit'])) {


$vert = $_POST['vert'];
$hor = $_POST['hor'];
$schuin = $_POST['schuin'];

$vert = pow($vert,2);
$hor = pow($hor,2);
$schuin = sqrt($vert + $hor);

echo $schuin;

}
?>
Answers: