[Solved] Nested condition using PHP

user330 Asks: Nested condition using PHP
I have two PHP files, assuming form.php and imple.php. form.php has three fields and it does work properly. I insert numbers in these fields to get a specific number. For example, when I sum or subtract the fields (e.g.,h1-h2+h3), by entering numbers in the fields ( h1,h2 and h3), I do not get any error. However, when I replace the formula with a nested condition and then run form.php, it says the page is not working. I have used the following codes for imple.php to get the outcome for imple.php:

Code:
<?php
session_start();
if(isset($_POST['h1'])){
    
    $flag = 0;
    if (!is_numeric($_POST['h1'])) { $flag = 1; }
    if (!is_numeric($_POST['h2'])) { $flag = 1; }
    if (!is_numeric($_POST['h3'])) { $flag = 1; }
    if($flag==1){
    
        $_SESSION['error'] = ' Need a numeric value.';
        header("Location: form.php");
    }else{
    
        if ($h2 < $h3){
            $outcome = ($h1)/$h2);
    }
    else {
        if ($h3 < 60){
            if ($h2 < $h3){
                $outcome = ($h3-$h2)/($h3-$h1);
            }
            else {
                $outcome = (100-$h2)/(100-$h3);
            }
        }
        else {
            $outcome = (100-$h1);
        }
    }
    $_SESSION['estimate'] = $outcome;
    if($outcome<50){
        $type = 'low';
    }else{
        $type='high';
    }
    $_SESSION['type'] = $type;
}else{
    $_SESSION['estimate'] = 0;
    $_SESSION['type'] = 'Null';
}
    
header("Location: form.php");
        
?>

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.